1. 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: CLIENT
C_ID Client Name City P_ID
01 TalcomPowder Delhi FW05
06 Face Wash Mumbai BS01
12 Bath Soap Delhi SH06
15 Shampoo Delhi FW12
16 Face Wash Banglore TP01
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
(i) To display the details of those clients whose city is Delhi.
(ii) To display the details of Products who’s Price is in the range of 50 to 100.(both values included)
(iii) To display the clientname, city from table client, and productname and price from table Product, with their
corresponding matching P_id
(iv) To increase the price of all products by 10.
(v) SELECT DISTINCT City FROM Client;
(vi) SELECT Manufacturer, MAX(Price), Min(Price), Count(*) FROM Product GROUP BY Manufacturer;
(vii) SELECT ClientName, ManufacturerName FROM Product, Client WHERE
Client.P_Id=Product.P_Id;
(viii) SELECT ProductName, Price * 4 FROM Product;
2. Consider the following tables Item and Customer.
Write SQL commands for the statement (i) to (iv) and give outputs for SQL queries (v) to
(viii)
Table:CUSTOMER
C_ID Cust_Name City I_ID
01 N.Roy Delhi LC03
06 H.Singh Mumba PC03
i
12 R.Pandey Delhi PC06
15 C.Sharma Delhi LC03
16 K.Agarwalh Banglo PC01
re
Table: ITEM
I_ID ItemName Manu Price
PC01 Personal ABC 35000
Computer
LC05 Laptop ABC 55000
PC03 Personal XYZ 32000
Computer
PC06 Personal COMP 37000
Computer
LC03 Laptop PQR 57000
(i) To display the details of those Customers whose city is Delhi.
(ii) To display the details of Item whose Price is in the range of 35000 to 55000 (Both values included).
(iii) To display the CustomerName, City from table Customer, and ItemName and Price from table Item, with
their corresponding matching I_ID.
(iv) To increase the Price of all Items by 1000 in the table Item.
(v) SELECT DISTINCT City FROM Customer.
(vi) SELECT ItemName, MAX(Price), Count(*) FROM Item GROUP BY ItemName;
(vii) SELECT CustomerName, Manufacturer FROM Item, Customer WHERE Item.Item_Id=Customer.Item_Id;
(viii) SELECT ItemName, Price * 100 FROM Item WHERE Manufacturer = ‘ABC’;
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
3. Consider the following tables Consignor and Consignee. Write SQL
command for the statements(i)to(iv)
Table: Consignor
Table: Cosignee
CnorID CnorNAme CnorAddress City
ND01 R Singhal 24, ABC Enclave New Delhi
ND02 Amit Kumar 123,Palm Avenue New Delhi
MU15 R Kohil 5/A,South Street Mumbai
MU50 S Kaur 7-K, Westend Mumbai
(i) To display the names of all consignors from Mumbai.
(ii) To display the cneeID, cnorName, cnorAddress, CneeName, CneeAddress for every Consignee.
(iii) To display the consignee details in ascending order of CneeName.
(iv) To display number of consignors from each city.
4. 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).
Table : FLIGHTS
FL_NO STARTING ENDING NO_ NO_ STOPS
FLGHTS
IC301 MUMBAI DELHI 8
IC799 BANGALOR DELHI 2
E
MC101 INDORE MUMBAI 3
IC302 DELHI MUMBAI 8
AM812 KANPUR BANGLORE 3
IC899 MUMBAI KOCHI 1
AM501 DELHI TRIVENDRU 1
M
MU499 MUMBAI MADRAS 3
IC701 DELHI AHMEDABAD 4
Table: FARES
FL_NO AIRLINES FARE TAX%
IC701 INDIAN AIRLINES 6500 10
MU499 SAHARA 9400 5
AM501 JET AIRWAYS 13450 8
IC899 INDIUAN AIRLINES 8300 4
IC302 INDIAN AIRLINES 4300 10
IC799 INDIAN AIRLINES 1050 10
MC101 DECCAN AIRLINES 3500 4
(i) To display fl_no, no_flights starting from ‘kanpur’ to ‘Bangalore’
(ii) Arrange the contents of the table FLIGHTS in the ascending order of FL_NO.
(iii)Display the minimum fare “Indian Airlines” is offering from the tables FARES.
(iv) To Display the FL_NO and fare to be paid for the flights from DELHI to MUMBAI using tables FLIGHTSand FARES,
where the fare to paid = FARE+FARE+TAX%/100.
(v) Select FL_NO,NO_FLIGHTS,AIRLINES from FLIGHTS, FARES Where STARTING = “DELHI” AND FLIGHTS.FL_NO =
(vi) SELECT count (distinct ENDING) from FLIGHTS;
5. Study the following tables DOCTOR and SALARY and write SQL commands for the questions (i)
to (iv) and give outputs for SQL query (v):
TABLE : DOCTOR:
ID NAME DEPT SEX EXPERIENC
E
101 Johan ENT M 12
104 Smith ORTHOPEDIC M 5
107 George CARDIOLOGY M 10
114 Lara SKIN F 3
109 George MEDICINE F 9
105 Johnson ORTHOPEDIC M 10
117 Lucy ENT F 3
111 Bill MEDICINE F 12
130 Murphy ORTHOPEDIC M 15
TABLE: SALARY
ID BASI ALLOWANCE CONSULTAIO
C N
101 12000 1000 300
104 23000 2300 500
107 32000 4000 500
114 12000 5200 100
109 42000 1700 200
105 18900 1690 300
130 21700 2600 300
(i) Display NAME of all doctors who are in “MEDICINE” having more than 10 years experience from the Table
DOCTOR.
(ii) Display the average salary of all doctors working in “ENT” department using the tables DOCTORS and SALARY
( Salary =BASIC+ALLOWANCE)
(iii) Display the minimum ALLOWANCE of female doctors.
(iv) Display the highest consultation fee among all male doctors.
(v) SELECT count (*) from DOCTOR where SEX= “F”;
--