SELECT DISTINCT city, country FROM customers; is executed. What exactly is deduplicated?
Correct answer
D. Whole (city, country) pairs, so a city may still appear once per distinct country
15 views
D. Whole (city, country) pairs, so a city may still appear once per distinct country
15 views
DISTINCT removes duplicate rows from the whole select list, so the (city, country) pair is the unit of comparison, not the first column alone. To deduplicate one column while keeping the others you need DISTINCT ON in PostgreSQL or a window function such as ROW_NUMBER. COUNT(DISTINCT city) counts unique cities without changing the row shape.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is D? Ask here and get an explanation.