193k views
4 votes
Write a SQL SELECT query that only returns each city once from the Students table. Do you need to order this list with an ORDER BY clause?

a) SELECT DISTINCT City FROM Students; No ORDER BY needed.
b) SELECT UNIQUE City FROM Students; ORDER BY required.
c) SELECT City FROM Students GROUP BY City; No ORDER BY needed.
d) SELECT City FROM Students; ORDER BY required.

User Bitmap
by
7.6k points

1 Answer

4 votes

Final answer:

The correct answer is SELECT DISTINCT City FROM Students; No ORDER BY needed.

Step-by-step explanation:

The correct answer is a) SELECT DISTINCT City FROM Students; No ORDER BY needed.

The SELECT DISTINCT keyword allows us to retrieve only unique values from a column in a table. In this case, it returns each city only once from the Students table.

Since the question does not specify any particular order in which the cities should be displayed, an ORDER BY clause is not needed.

User Julieanne
by
8.6k points