What does SELECT DISTINCT city FROM customers return?
Correct answer
C. Each city value once, with duplicates removed
15 views
C. Each city value once, with duplicates removed
15 views
DISTINCT removes duplicate result rows, so a city appearing on fifty customer records is listed once, giving the set of unique values rather than a frequency count. GROUP BY city with COUNT(*) answers a different question by returning how many customers each city has. With several selected columns, DISTINCT tests the whole tuple, so the combination is unique even when individual columns repeat.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.