Skip to content
Question 76 of 95

Q.Write the output of SQL queries

(a) to
(d) based on the table VACCINATION_DATA given below: Table: VACCINATION_DATA VID Name Age Dose1 Dose2 City 101 Jenny 27 2021-12-25 2022-01-31 Delhi 102 Harjot 55 2021-07-14 2021-10-14 Mumbai 103 Srikanth 43 2021-04-18 2021-07-20 Delhi 104 Gazala 75 2021-07-31 NULL Kolkata 105 Shiksha 32 2022-01-01 NULL Mumbai
(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;
Tamil Nadu DgeCBSE Class XII Board 2022Subjective· 2mImportance★★★★★
80% · 76/95 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

These SQL queries retrieve filtered records, aggregate counts by city, list unique cities, and find extreme vaccination dates from the VACCINATION_DATA table.

Understanding the Table Structure

The VACCINATION_DATA table tracks vaccination records for five individuals. Each row contains a unique identifier (VID), personal details (Name, Age), two dose dates (Dose1, Dose2), and the City of residence. Notice that Gazala and Shiksha have NULL values in Dose2, meaning they haven't received their second dose yet—this detail matters when filtering or aggregating data.

Query (a): Filtering by Age and Completion Status

SELECT Name, Age FROM VACCINATION_DATA WHERE Dose2 IS NOT NULL AND Age > 40;

This query asks for names and ages of people who meet two conditions: they must have completed both doses (Dose2 IS NOT NULL) and be older than 40. Walking through the table:

  • Jenny (27) fails the age test
  • Harjot (55) passes both—has Dose2 and is over 40
  • Srikanth (43) passes both—has Dose2 and is over 40
  • Gazala (75) passes the age test but has NULL in Dose2
  • Shiksha (32) fails both conditions

Output:

NameAge
Harjot55
Srikanth43

Query (b): Counting Records by City

SELECT City, COUNT(*) FROM VACCINATION_DATA GROUP BY City;

GROUP BY collapses rows sharing the same City value into groups, and COUNT(*) tallies how many records fall into each group. Delhi appears twice (Jenny, Srikanth), Mumbai twice (Harjot, Shiksha), and Kolkata once (Gazala).

Output:

CityCOUNT(*)
Delhi2
Mumbai2
Kolkata1
Note

The order of cities in the output depends on the database implementation—SQL doesn't guarantee any particular sequence unless you add ORDER BY.

Query (c): Listing Unique Cities

SELECT DISTINCT City FROM VACCINATION_DATA;

DISTINCT eliminates duplicate values, so even though Delhi and Mumbai each appear twice in the table, they're listed only once in the result.

Output:

City
Delhi
Mumbai
Kolkata

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.