1. Home
  2. Data Science
  3. SQL for Data Analysis
  4. What does SELECT DISTINCT city FROM customers return?

Added 30 Nov -0001

What does SELECT DISTINCT city FROM customers return?

  1. Only the cities that appear exactly once
  2. The count of customers in each city
  3. Each city value once, with duplicates removed Correct answer
  4. Every customer row with the city column added

Correct answer

C. Each city value once, with duplicates removed

15 views

MCQSEXAM

Explanation

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.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More SQL for Data Analysis MCQs

Practise all SQL for Data Analysis MCQs

Similar MCQs