SQL Practice Question
SQL Practice Question
SQL Practice Question
Practice Questions
By:-
Amit Yerpude
PGT (Computer Science)
Kendriya Vidyalaya , Khagaria
By:- Amit Yerpude, PGT 8/6/2020
CS, KV Khagaria
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)
C_ID Client Name City P_ID P_ID Product Name Manufacturer Price
01 TalcomPowder Delhi FW05 TP01 TalcomPowder LAK 40
06 Face Wash Mumbai BS01 FW05 Face Wash ABC 45
12 Bath Soap Delhi SH06 BS01 Bath Soap ABC 55
15 Shampoo Delhi FW12 SH06 Shampoo XYZ 120
Banglor FW12 Face Wash XYZ 95
16 Face Wash TP01
e
By:- Amit Yerpude, PGT 8/6/2020
CS, KV Khagaria
(vi) SELECT Manufacturer, MAX(Price), Min(Price), Count(*) FROM Product GROUP BY Manufacturer;
Ans:
Manufacturer Max(Price) Min(Price) Count(*)
LAK 40 40 1
ABC 55 45 2
XYZ 120 95 2
(viii) SELECT ItemName, Price * 100 FROM Item WHERE Manufacturer = ‘ABC’;
Ans:
ItemName Price*100
Personal Computer 3500000
Laptop 5500000
By:- Amit Yerpude, PGT 8/6/2020
CS, KV Khagaria
TABLE : CONSIGNOR
CneeID CnorID CneeName CneeAddress CneeCity
MU05 ND01 RahulKishore 5,Park Avenue Mumbai
ND08 ND02 P Dhingr a 16/j,Moore Enclave New Delhi
KO19 MU15 A P Roy 2A,Central/ avenue Kolkata
MU32 ND0 2 S mittal P 245, AB Colony Mumbai
ND48 MU5 0 B P jain 13,Block d,a,viha New Delhi
TABLE : CONSIGNEE
CnorID CnorName CnorAddress City
Study the following tables FLIGHTS and FARES and write SQL
commands for the questions (i) to (iv) and give outputs for
SQL quires (v) to(vi).
FL_NO STARTING ENDING NO_ FLGHTS NO_ STOPS
IC301 MUMBAI DELHI 8 0
TABLE: FLIGHTS
IC799 BANGALORE DELHI 2 1
MC101 INDORE MUMBAI 3 0
IC302 DELHI MUMBAI 8 0
AM812 KANPUR BANGLORE 3 1
IC899 MUMBAI KOCHI 1 4
AM501 DELHI TRIVENDRUM 1 5
MU499 MUMBAI MADRAS 3 3
IC701 DELHI AHMEDABAD 4 0
(iii) Display the FL_NO and fare to be paid for the flights from
DELHI to MUMBAI using the tables FLIGHTS and FARES,
where the fare to paid = FARE+FARE+TAX%/100.
Ans: Select FL_NO, FARE+FARE+(TAX%/100) from
FLIGHTS, FARES where Starting=”DELHI” AND
Ending=”MUMBAI”
Thank you!!!