samedi 23 février 2019

How sort by two values as desc in one sql query?

I have advertisements table. In there i have two dates. You can put adv and add option to show top on the list. I created top_list_end_date and i can order by that date is simple. is another date up_date if your adv is on second page or on bottom you can up date and looks like fresh adv should be on top of the list.

SELECT id, up_date, top_list_end_date 
FROM advertisements
ORDER BY top_list_end_date desc, up_date desc;

But doesnt work. enter image description here I would like adv id 202 as first in results cause up_date is higher. How can i do this in one sql ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire