I have a simple query which queries by item_id and it obviously works because it is so simple.
What I need to do is change it to also take into account the updated date, and be something similar to this:
select item_id , item_name from items order by item_id , update_date desc limit 200
So the requirement is:
- Order by update_date and tie break by item_id.
- Where update_date is null, just rank it by item_id.
How can I do that?
Thanks!
When your sorting, SQL will sort by the order the fields are listed in the query in succession, so in the below example
it will order by update_date first, then order those(sorted) results by item_id, both descending.