How to order by column if equal, order by another
You can specify more than one column in the order by
clause:
select * from table order by col1, col2;
This will order by col1
, then order by col2
when col1
is equal. You can also specify ascending and descending separately for each column:
select * from table order by col1 asc, col2 desc;
You can add multiple columns in your order by
clause.
select * from your_tableorder by col1, col2 desc
The result will be ordered by the first column and if equal by the next and so forth