mysql order by on condition

Solutions on MaxInterview for mysql order by on condition by the best coders in the world

showing results for - "mysql order by on condition"
Kamil
02 Jan 2021
1 SELECT * 
2    FROM my_table 
3    WHERE 1  
4    ORDER BY 
5      CASE price WHEN 0 THEN 1
6       ELSE -1
7      END ASC, price asc, id asc
8
Lilly
15 Feb 2019
1SELECT orders.status, orders.created_at
2FROM `orders`
3ORDER BY
4  status='new' DESC,
5  status='processing' DESC,
6  CASE WHEN status IN ('new', 'processing') THEN created_at END ASC,
7  CASE WHEN status NOT IN ('new', 'processing') THEN created_at END DESC
queries leading to this page
mysql order by id ascquery for descending order in mysql queryhow to order result before format mysqlorder by conditional in mysqldesc in mysqlorder by if mysql order by clause without where mysqlorder by my sqlsort conditions in mysqlorder by example in mysqloder mysqlorder by asc in mysqldisplay entries in ascending order in mysqlorder by mysqlmysql order byhow to order by in mysqlmysql order by based on conditionmysql select from where order byorder by and asc mysqlmysql how to sort a columnmysql orderby descset record asc mysqlmysql where and order bydecsending in mysqlmysql order by descendingmysql order querymysql order descmysql sort bywhere in order by mysql conditionsmysql sort if based on conditionorder by and where in mysqlusing and condition in order by mysqlorder by column mysqlascending order in mysql query with examplewhere order by mysqldisplay records in descending order in mysqlmysql sort by columnmysql sort by id ascmysql select by ordermysql sort by ascendingmysql desc ascasc mysqlmysql order by if desc by in mysqlmy sql order b 3cmysql order by on conditionmysql select 2a from servers sort bydesc mysqloderby ascending mysqlorder by in mysql without conditionmysql orderby sort condition in orderby mysqlmysql order by conditionsort column mysqlmysql order by idorder by matched conditions mysqlsort with if mysqlmysql result sortinghow to sort by column in mysqlmysql if in order bysortby mysqlconditional order by in mysqlsort in descending order in mysqlorder by if condition mysqlmysql order by conditionalmysql query sortorder by condition in mysqlmysql order by ascmysql asendingorder by mysql conditionsmysql order by where conditionmysql how to sort by columnmysql order by with where clausemysql where clause with order byorder by based on condition mysqlorder desc mysqlselect desc from table mysqlmysql order by and wheremysql order by wheremysql order by on condition