Given the table COUNTRY: NAME CITIES PERSON Argentina 30 1 Cuba 20 2 Canada 10 2 Germany 40 1 Given the statement: SELECT name,cities FROM country Which of the following clauses must be added to the statement for it to return rows sorted by NAME ascending and then sorted by CITIES ascending?
-
ORDER BY 2,1
-
ORDER BY 2 ASC, 1 ASC
-
ORDER BY 1,2
-
ORDER BY 1 ASC, 2 ASC
C,D
Correct answer
Explanation
In SQL, column positions in ORDER BY are 1-indexed based on the SELECT list: position 1 is NAME, position 2 is CITIES. To sort by NAME first then CITIES (both ascending), you can use 'ORDER BY 1,2' since ascending is the default. Option D explicitly specifies 'ASC' but is equivalent. Options A and B reverse the column order, sorting by CITIES first.