#NoPayJan Offer - Access all CloudxLab Courses for free between 1st to 31st Jan

  Enroll Now >>

Sorting the query results

By default, select can give rows in any order.

To get the data in order by certain columns, use 'order by'.

Syntax:

select field1, field2,...fieldN table_name1, table_name2...
order by field1, [field2...] [asc[desc]]

select * from deptt order by depcity asc,depstreet desc;

Sorting columns in 'order by' can also be referred to by column position in the 'select' expression rather than actual column names.

In below example, the result will be sorted by 2nd and 5th columns of the output.

select * from deptt order by 2,5;

No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...