1. Home
  2. Data Science
  3. SQL for Data Analysis
  4. Which clause sorts query results from highest to lowest in…

Added 30 Nov -0001

Which clause sorts query results from highest to lowest in SQL?

  1. ORDER BY amount DESC Correct answer
  2. ORDER BY amount ASC
  3. GROUP BY amount DESC
  4. SORT BY amount DESC

Correct answer

A. ORDER BY amount DESC

18 views

MCQSEXAM

Explanation

ORDER BY sorts the final result set, and DESC reverses the default ascending order, so the largest amounts appear first. GROUP BY is not a sorting clause at all: it collapses rows into groups and any apparent order is incidental and not guaranteed. NULL placement in sorted output varies by database, so explicit NULLS LAST is needed for portable behaviour.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? 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