Test Index

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

© examsnet.com
Question : 54 of 58
Marks: +1, -0
Write the output of SQL queries (a) to (d) based on the table VACCINATION_DATA given below :
TABLE : VACCINATION_DATA
VIDNameAgeDose1Dose2City
101Jenny272021-12-252022-01-31Delhi
102Harjot552021-07-142021-10-14Mumbai
103Srikanth432021-04-182021-07-20Delhi
104Gazala752021-07-31NULLKolkata
105Shiksha322022-01-01NULLMumbai
(a) SELECT  Name, Age FROM VACCINATION_DATA
WHERE Dose2 IS NOT NULL AND Age > 40;
(b) SELECT City, COUNT(*) FROM VACCINATION_DATA GROUP BY City;
(c) SELECT DISTINCT City FROM VACCINATION_DATA;
(d) SELECT MAX (Dose1), MIN (Dose2) FROM VACCINATION_DATA;
[CBSE 2022 Code 91]
Solution:  
(a) Rows with a second dose (Dose2 not NULL) and Age above 40: Harjot (55) and Srikanth (43). Gazala (75) has Dose2 NULL, so she is left out.
NameAge
Harjot55
Srikanth43
(b) Rows are grouped by City and counted:
CityCOUNT(*)
Delhi2
Mumbai2
Kolkata1
(c) Each city is shown only once:
City
Delhi
Mumbai
Kolkata
(d) Latest first-dose date and earliest second-dose date (NULL values are ignored by MIN):
MAX(Dose1)MIN(Dose2)
2022-01-012021-07-20
© examsnet.com
Advertisements
Go to Question: