Find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table.
The STATION table is described as follows:
SOLUTION:
SELECT COUNT(CITY)-COUNT(DISTINCT CITY) FROM STATION;
Explanation:
-
COUNT(*)
counts all rows (including duplicates and nulls in other columns, but not inCITY
directly). -
COUNT(DISTINCT CITY)
counts unique cities only. -
Subtracting the two gives you the number of duplicate city entries.