0% found this document useful (0 votes)
42 views

Dbms 3

This document contains the name, batch, and roll number of a student followed by 22 SQL queries to be answered related to displaying dates, finding days of the week, and inserting/selecting from tables. The student is asked to write queries to display dates and days in various formats, find the next Friday's date, round and truncate dates, and select records from an EMP table based on date of joining conditions. The student is also asked to create a TRAIN table, insert records, and write queries to display times and select trains arriving or departing at certain times.

Uploaded by

Panshul Saxena
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Dbms 3

This document contains the name, batch, and roll number of a student followed by 22 SQL queries to be answered related to displaying dates, finding days of the week, and inserting/selecting from tables. The student is asked to write queries to display dates and days in various formats, find the next Friday's date, round and truncate dates, and select records from an EMP table based on date of joining conditions. The student is also asked to create a TRAIN table, insert records, and write queries to display times and select trains arriving or departing at certain times.

Uploaded by

Panshul Saxena
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

DBMS Assignment 3

Name - Panshul Saxena


Batch - 2CS10
Roll No - 102196006

Write queries to:


1. Display the system date
2. Display current day
3. Display current month and spell out year
4. Display spell out current date
5. Check whether it is AM or PM right now
6. Display the date of next Friday
7. Round the system date on month
8. Truncate the system date on month
9. Round the system date on year
10. Truncate the system date on year
11. Find the day after three days

Answers- 1 to 11
select SYSDATE from dual;

select to_char(sysdate,'day') from dual;

select to_char(sysdate,'mm-year') from dual;

select to_char(sysdate,'ddspth Month Year') from dual;

select to_char(sysdate,'am') from dual;

select next_day(sysdate,'Friday') from dual;

select round(sysdate,'month') from dual;

select trunc(sysdate,'month') from dual;

select round(sysdate,'year') from dual;


select trunc(sysdate,'year') from dual;

select to_char(sysdate+3) from dual;


Queries Based on EMP table:
12. Display day of date of joining column
13. Display those employees who join the company on Monday
14. Display those employees who join the company this month
15. Display those employees who join the company in last 30
days
Answers- 12 to 15

CREATE TABLE employee (


empno int,
ename varchar(20) ,
job varchar(50),
deptno int,
sal int,
commission int,
date_ofjoining date
);
INSERT INTO employee VALUES (101, 'Aman', 'Manager', 10 ,
3000 , NULL,DATE'2003-02-17');
INSERT INTO employee VALUES (201, 'Ashneer', 'Assistant
Manager', 11 , 2000 , NULL,DATE'2003-06-11');
INSERT INTO employee VALUES (301, 'Peyush', 'Treasurer', 20 ,
706 , 0.7,DATE'2004-12-26');
INSERT INTO employee VALUES (401, 'Anupam', 'Clerks', 10 , 8554
, 0.9,DATE'2006-08-05');
INSERT INTO employee VALUES (501, 'Vineeta', 'Salesperson', 14 ,
975 , 1.4,DATE'2008-09-20');

select to_char(date_ofjoining,'Day') day_ofjoining from


employee;

select * from employee where


trim(to_char(date_ofjoining,'Day'))='Monday';
select * from employee where
to_char(sysdate,'mm')=to_char(date_ofjoining,'mm');

select * from employee where sysdate-date_ofjoining<=30;

Create a table train having three four columns:


16. Train Number, date of Departure, time of departure, time of
arrival.
17. Insert five columns in train table.
18. Display all the records.
19. Display the time values inserted in the columns.
20. Display those trains which arrived on PM.
21. Display train number who are going to depart in next one
hour.
Answers- 16 to 21
create table tr(tn number(3),dod date,tod timestamp,toa
timestamp);
insert into tr values(100,'11-AUG-2021','11-AUG-2021 07:34:00
PM','12-JAN-2021 06:55:00 PM');
insert into tr values(101,'12-AUG-2021','14-AUG-2021 02:34:00
PM','10-JAN-2021 01:05:00 AM');
insert into tr values(102,'31-AUG-2021','31-AUG-2021 11:30:00
PM','30-MAR-2021 11:15:00 PM');
insert into tr values(103,'11-AUG-2021','11-AUG-2021 05:34:00
PM','01-FEB-2021 05:24:00 PM');
insert into tr values(104,'11-AUG-2021','11-AUG-2021 06:10:00
AM','23-DEC-2021 06:00:00 AM');

select * from tr;

select tod,tod from tr;

select * from tr where to_char(toa,'PM') = 'PM';

select tn from tr where to_char(tod,'HH24') =


to_char(Current_Timestamp+0.04166,'HH24');

You might also like