Order by is used to sort the select results. It is very simple, but let's summarize it.
1. sort by column name. The default value is ascending.
Single Column Ascending Order: Select <column_name> from <table_name> order by <column_name>;
Single Column descending order: Select <column_name> from table_name order by <column_name> DESC;
Multi-column Ascending Order: Select <column_one>, <column_two> from table_name order by <column_one>, <column_two>;
Multi-column descending order: Select <column_one>, <column_two> from <table_name> order by <column_one> DESC, <column_two> DESC;
Multi-column hybrid descending order: Select column_one, column_two from table_name order by column_one DESC, column_two DESC;
2. sort by column in ascending order by default
Select * from <table_name> order by 1
3. null sorting
Null before: Select <column_name> from <table_name> order by <column_name> nulls first;
After the null value is: Select <column_name> from <table_name> order by <column_name> nulls last;