Test Index

Structured Query Language (SQL) Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 55 of 58
Marks: +1, -0
Write the output of SQL queries (a) and (b) based on the following two tables DOCTOR and PATIENT belonging to the same database :
Table : DOCTOR
DNODNAMEFEES
D1AMITABH1500
D2ANIKET1000
D3NIKHIL1500
D4ANJANA1500
Table : PATIENT
PNOPNAMEADMDATEDNO
P1NOOR2021-12-25D1
P2ANNIE2021-11-20D2
P3PRAKASH2020-12-10NULL
P4HARMEET2019-12-20D1
(a) SELECT DNAME, PNAME FROM DOCTOR
NATURAL JOIN PATIENT ;
(b) SELECT PNAME, ADMDATE, FEES
FROM PATIENT P, DOCTOR D
WHERE D.DNO = P.DNO AND FEES > 1000;
[CBSE 2022 Code 91]
Solution:  
(a) NATURAL JOIN matches the rows on the common column DNO. Patient P3 (DNO NULL) and doctors D3, D4 (no patient) do not appear.
DNAMEPNAME
AMITABHNOOR
AMITABHHARMEET
ANIKETANNIE
(The order of the rows may differ; the three pairs are the answer.)
(b) Only doctor D1 (AMITABH) among the matched doctors has FEES > 1000 (ANIKET's fee is exactly 1000, so it is excluded):
PNAMEADMDATEFEES
NOOR2021-12-251500
HARMEET2019-12-201500
© examsnet.com
Advertisements
Go to Question: