Professional Documents
Culture Documents
SCIENCE
SQL
ACKNOWLEDGEMENT
I would like to express my special gratitude to my
teacher who gave me the golden opportunity to do
this wonderful project on the topic “ STRUCTURED
QUERY LANGUAGE “ which also helped me in doing
a lot of Research and I came to know about so many
new things I am really thankful to them.
Secondly I would also like to thank my parents and
friends who helped me a lot in finalizing this project
within the limited time frame.
INDEX
SNO. NAME OF TABLE TEACHER’S SIGN
SCHOOL
1 ADMIN
WORKER
2 PAYLEVEL
PRODUCT
3 CLIENT
SENDER
4 RECEPIENT
STORE
5 ITEM
EMPLOYEE
6 SALGRADE
CONSIGNER
7 CONSIGNEE
CARDEN
8 CUSTOMER
DEPT
9 EMPLOYEE
GAMES
10 PLAYERS
TABLE 1
QUES 1 :Consider the following tables SCHOOL and ADMIN. Write SQL commands for the statements (i) to (iv) and
give outputs for SQL queries (v) to (viii).
SCHOOL
CODE TEACHER NAME SUBJECT DOJ PERIODS EXPERIENCE
1001 RAVI SHANKAR ENGLISH 12/03/2000 24 10
1009 PRIYA RAI PHYSICS 03/09/1998 26 12
1203 LISA ANAND ENGLISH 09/04/2000 27 5
1045 YASHRAJ MATHS 24/08/2000 24 15
1123 GANAN PHYSICS 16/07/1999 28 3
1167 HARISH B CHEMISTRY 19/10/1999 27 5
1215 UMESH PHYSICS 11/05/1998 22 16
ADMIN
ENGLISH 10
PHYSICS 16
MATHS 15
CHEMISTRY 5
QUES2: Consider the following tables WORKER and PAYLEVEL and answer (a) and (b) parts of this questions:
Table: WORKER
ECODE NAME DESIGN PLEVEL DOJ DOB
11 RadheShyam Supervisor P001 13-Sep-2004 23-Aug-1981
12 ChanderNath Operator P003 22-Feb-2010 12-Jul-1987
13 Fizza Operator P003 14-Jun-2009 14-Oct-1983
15 Ameen Ahmed Mechanic P002 21-Aug-2006 13-Mar-1984
18 Sanya Clerk P002 19-Dec-2005 09-Jan-1983
Table: PAYLEVEL
PLEVEL PAY ALLOWENCE
P001 26000 12000
P002 22000 10000
P003 12000 6000
a) Write SQL commands for the following statement:
1. To display the details of all WORKERS in descending order of DOB.
Select * from WORKERS order by DOB desc;
2. To display NAME and DESIGN of those WORKERS, whose PLEEL is either P001 or P002.
Select NAME , DESIGN from WORKERS where PLEVEL In ( P001 , P002);
3. To display the content of all the WORKERS table, whose DOB is in between
‘19-JAN-1984’ and ’18-JAN-1987’.
Select * from WORKER where DOB between ‘19-JAN-1984’ and ’18-JAN-1987’;
4. To add a new row with the following:
19, ‘Daya Kishore’, ‘Operator’, ‘P003’, ’19-JUN-2008’, ’11-JUL-1984’
Insert into WORKER
Values (19, ‘Daya Kishore’, ‘Operator’, ‘P003’, ’19-JUN-2008’, ’11-JUL-1984’ );
QUES 3 : Consider the following tables Product and Client. Write SQL commands for the statement (i) to
(iv) and give outputs for SQL queries (v) to (viii)
Table: PRODUCT
P_ID Product Name Manufacturer Price
TP01 TalcomPowder LAK 40
FW05 Face Wash ABC 45
BS01 Bath Soap ABC 55
SH06 Shampoo XYZ 120
FW12 Face Wash XYZ 95
Table: CLIENT
C_ID Client Name City P_ID
01 Cosmetic Shop Delhi FW05
06 Total Health Mumbai BS01
12 Live Life Delhi SH06
15 Pretty Woman Delhi FW12
16 Dreams Banglore TP01
(i) To display the details of those Clients whose city is Delhi.
Select * from Client where City=”Delhi”;
(ii) To display the details of Products whose Price is in the range of 50 to 100.
Select * from product where Price between 50 and 100;
(iii) To display the ClientName, City from table Client, and ProductName and Price from table Product, with their
corresponding matching P_ID.
Select ClientName,City,ProductName, Price from Product,Client where Product.P_ID=Client.P_ID.
(iv) To increase the Price of all Products by 10
Update Product Set Price=Price +10;
(v) SELECT DISTINCT City FROM Client
City
Delhi
Mumbai
Bangalore
(vi) SELECT Manufacturer, MAX(Price), Min(Price), Count(*) FROM Product GROUP BY Manufacturer;
QUES 4 ;Consider the following tables. Write SQL command for the statements (i)to(iv)and give outputs for the
SQL quries (v) to (viii).
TABLE : SENDER
Sender
SenderID SenderName Sender Address
City
ND01 R jain 2,ABC Appts New Delhi
MU02 H sinha 12, Newton Mumbai
27/ A,Park
MU1 5 S haj New Delhi
Street
ND5 0 T Prasad 122-K,SDA Kolkata
TABLE :RECIPIENT
QUES 5 : Consider the following tables STORE and ITEM and answer the following questions :-
TABLE : STORE
SNo SName Area
S01 ABC Conputronics GK 2
S02 All Infotech Media CP
S03 Tech Shoppe Nehru Palace
S04 Geeks Techno Soft Nehru Palace
S05 Hitech Tech Store CP
TABLE: ITEM
INo IName Price SNo
T01 Mother board 12000 S01
T02 Hard Disk 5000 S01
T03 Keyboard 500 S02
T04 Mouse 300 S01
T05 Mother Board 13000 S02
T06 Key Board 400 S03
T07 LCD 6000 S04
T08 LCD 5500 S05
T09 Mouse 350 S05
T10 Hard Disk 4500 S03
4. Select IName ,Price *0.05 discount from ITEM where SNo In(‘S02’,’S03’);
IName Discount
Key Board 25
Mother Board 650
Keyboard 20
Hard Disk 225
QUES 6 : Consider the following tables EMPLOYEE and SALGRADE and answer the following:-
TABLE : EMPLOYEE
ECODE NAME DESIG SGRADE DOJ DOB
101 ABDUL EXECUTIVE S03 23-03-2003 13-01-1980
102 RAVI HEAD – IT S02 12-02-2010 22-07-1987
103 JOHN RECEPTIONIST S03 24-06-2009 24-02-1983
105 NAZAR GM S02 11-08-2006 03-03-1984
108 PRIYAM CEO S01 29-12-2004 19-01-1982
TABLE : SALGRADE
SGRADE SALARY HRA
S01 56000 18000
S02 32000 12000
S03 24000 8000
Table: CONSIGNEE
CneeID CnorId CneeName CneeAddress CneeCity
MU05 ND01 Rahul Kishore 5, Park Avenue Mumbai
ND08 ND02 P Dhingra 16/J, Moore Enclave New Delhi
KO19 MU15 A P Roy 2A, Central Avenue Kolkata
MU32 ND02 S Mittal P245, AB Colony Mumbai
ND48 MU50 B P Jain 13, Block D, A Vihar New Delhi
CnorName CneeName
R singhal Rahul Kishore
Amit Kumar S mittal
(vii) SELECT CneeName, CneeAddress FROM Consignee WHERE CneeCity NOT IN (‘Mumbai’, ‘Kolkata’);
CneeName CneeAddress
P Dhingra 16/j,Moore Enclave
B P jain 13,Block d,a,viha
(viii) SELECT CneeID, CneeName FROM Consignee WHERE CnorID= ‘MU15’n R CnorID = ‘ND01’;
MU05 Rahul Kishore
K019 AP ROY
QUES: 8. Consider the following tales CARDEN and CUSTOMER and answer (a) and (b) parts of this questions:
Table: CARDEN
CCODE Car Name Make Color Capacity Charges
501 A-Star Suzuki RED 3 14
503 Indigo Tata SILVER 3 12
502 Innova Toyota WHITE 7 15
509 SX4 Suzuki SILVER 4 14
510 C-Class Mercedes RED 4 35
Table: CUSTOMER
Code CName Ccode
1001 Hemant Sahu 501
1002 Raj Lal 509
1003 Feroza Shah 503
1004 Ketan Dhal 502
1. To display WNO , name , gender, from the table EMPLOYEE in descending order of WNO.
Select WNO , Name , Gender , from EMPLOYEE order by WNO desc;
2. To display the name of all the MALE employee from the table.
Select Name from EMPLOYEE where Gender=’MALE’;
3. To display the WNO and name of those workers from the table EMPLOYEE who are born between ‘1987-
01-01’ and ‘1991-12-01’ .
Select WNO, Name from EMPLOYEE where DOB between ‘1987-01-01’ and ‘1991-12-01’ ;
4. To count and display female employees who have joined after ‘1986-01-01’.
Select count (FEMALE) from EMPLOYEE where DOJ>’1986-01-01’;
5. SELECT COUNT(*), DCODE FROM EMPLOYEE GROUP BY DCODE HAVING COUNT(*) >1;
5
6. SELECT DISTINCT DEPARTMENT FROM DEPT;
MEDIA
MARKETING
INFRASTRUCTURE
FINANCE
HUMAN RESOURCE
7. SELECT NAME , DEPARTMENT , FROM EMPLOYEE E , DEPT D WHERE E.DCODE=D.DCODE AND WNO<1003;
MEDIA DELHI
INFRASTRUCTURE MUMBAI