🐘Order By

Describe about Order By command

Order by is a command to sort row of the data when we retrieve data from table.

Using PostgreSQL ORDER BY clause to sort rows by one or multiple column

// ASC is a default value
SELECT	first_name, last_name FROM customer ORDER BY first_name ASC, last_name DESC;

In case that you have null value you can choose the condition for sort by using NULLS FIRST | NULLS LAST

example

// NULLS FIRST is a default value
SELECT	first_name, last_name FROM customer ORDER BY first_name, last_name DESC NULLS LAST;

Last updated