Table: PATIENT Table: DOCTOR Pname Age Ward Admitdate Tariff Sex Ward Dname
Table: PATIENT Table: DOCTOR Pname Age Ward Admitdate Tariff Sex Ward Dname
Write SQL commands for b) to g) on the basis of tables PATIENT and DOCTOR
Table: PATIENT Table: DOCTOR
PNAME AGE WARD ADMITDATE TARIFF SEX WARD DNAME
KAREEM 32 ORTHO 2012-02-19 600 M ENT KAPIL GUPTA
ARUN 12 SURGERY 2012-11-01 900 M ORTHO AMARJIT BEDI
ZAFAR 30 ENT 2012-01-12 750 M SURGERY PRADIP JAIN
KIRAN 16 ENT 2012-02-24 750 F CARDIO NIRMAL SINHA
ANKITA 29 CARDIO 2012-02-20 800 F
SUHAIL 45 ORTHO 2012-02-22 600 F
KETAN 19 CARDIO 2012-01-13 800 M
SHILPA 23 SURGERY 2012-02-21 900 F
ARPRIT 42 CARDIO 2012-02-23 800 M
TARUN 53 SURGERY 2012-01-17 900 M
b) List the complete information of all male patients in SURGERY ward from PATIENT table
c) Increase the TARIFF (daily charge) of ORTHO ward by 15%.
d) Display a report showing PNAME, AGE, WARD and weekly TARIFF
e) Add 'JULIAN', 24, 'CARDIO', '2012-05-29', 800, 'M' in the PATIENT table
f) Count the number of patients in each ward
g) Give the output of the following SQL commands:
i) SELECT SEX, COUNT(SEX) FROM PATIENT GROUP BY SEX;
ii) SELECT MAX(ADMITDATE), MIN(ADMITDATE) FROM PATIENT;
iii) SELECT SUM(TARIIF), AVG(TARIFF) FROM PATIENT
WHERE WARD IN ('CARDIO', 'ORTHO');
iv) SELECT PNAME, DNAME FROM PATIENT P, DOCTOR D
WHERE P.WARD=D.WARD AND P.WARD='ENT';
Answer SQL questions b) to h) on the basis of tables SUPPLIER and STORE given below.
Table: SUPPLIER Table: STORE
SNO NAME AREA ITEM PRICE SNO
S01 COMPUTER MART CHADNI CHOWK MOTHER BOARD 15000 S01
S02 COMPUTER POINT RAJEEV CHOWK HARD DISK 5000 S01
S03 HARDWARE HOME NEHRU PLACE KEYBOARD 600 S02
S05 TECHNO SHOP KAMLA NAGAR MOUSE 250 S01
MOTHER BOARD 16000 S02
KEY BOARD 500 S03
LED MONITOR 6000 S04
LED MONITOR 5000 S05
MOUSE 500 S05
HARD DISK 4500 S03
b) Display ITEM and PRICE from STORE in the ascending order of their PRICE
c) Display the SNO and NAME from SUPPLIER located in RAJEEV CHOWK
d) Display the minimum and maximum PRICE of each ITEM from the table STORE
e) Display the details of ITEMs whose PRICE is in the range 1000 to 3000 using table the SRORE
f) Display the ITEM, PRICE and NAME using tables STORE and SUPPLIER
g) Increase the PRICE of each ITEM by 50 whose SNO is either 'S01' or 'S03'
h1) SELECT DISTINCT ITEM FROM SRORE WHERE PRICE>=5000;
h2) SELECT SNO, COUNT(*) FROM STORE GROUP BY SNO HAVING COUNT(*)>1;
h3) SELECT PRICE, AREA FROM STORE X, SUPPLIER Y
WHERE X.SNO=Y.SNO AND ITEM IN ('HARD DISK', 'MOUSE');
h4)SELECT ITEM, 0.05*PRICE DISCOUNT FROM STORE WHERE SNO='S05';
Page 1 of 4
3. a) Differentiate between
i) DDL and DML commands of SQL ii) Cardinality and Degree
6. a) Differentiate between Candidate key and Alternate key with suitable example.
b) Write SQL commands for the statements i) to iv) and give outputs for SQL queries v) to viii)
Table: SENDER
SID SNAME SADDRESS SCITY
ND01 RAHUL JAIN 2B/16 JANAK PURI NEW DELHI
MU02 HARSH SINHA H12-34 NEW TOWN MUMBAI
MU15 PRADIP JHA 27/A PARK STREET MUMBAI
ND50 TARUN PRASAD 122K VASANT KUNJ NEW DELHI
Table: RECIPIENT
RID SID RNAME RADRESS RCITY
KO05 ND01 RAVI BAJPAYEE 5/24 CENTRAL AVENUE KOLKATA
ND08 MU02 SUNIT MAHAJAN 116-D ANAND VIHAR NEW DELHI
MU19 ND01 HARDIK SINGH 2A-29 ANDHERI EAST MUMBAI
MU32 MU15 PRANAV SWAMY B5/30 BANDRA WEST MUMBAI
ND48 ND50 SANJAY TRIPATHI 13 BL-D, MAYUR VIHAR NEW DELHI
i) Display the names of all SENDERS from MUMBAI
ii) Display the RID, SNAME, SADDRESS, RNAME, RADDRESS of every RECIPIENT
iii) Display Recipient details in ascending order of RNAME
iv) Display number of Recipients from every city
v) SELECT DISTINCT SCITY FROM SENDER;
vi) SELECT A.SNAME, B.RNAME FROM SENDER A, RECIPIENT B
WHERE A.SID=B.SID AND B.RCITY='MUMBAI';
vii) SELECT RNAME, RADDRESS FROM RECIPIENT
WHERE RCITY NOT IN ('MUMBAI', 'KOLKATA');
viii) SELECT RID, RNAME FROM RECIPIENT WHERE SID IN ('MU02', 'ND50');
Page 3 of 4
7. a) Explain Union of two tables using a suitable example.
Page 4 of 4