Mysql
 sql >> Datenbank >  >> RDS >> Mysql

sql Union-Reihenfolge

   SELECT *
   FROM students
   ORDER BY IF(height >= 150, 1,0 ) DESC, 
            IF(height >= 150, name, '') ASC, 
            name DESC

Beispielausgabe

+------+--------+
| name | height |
+------+--------+
| a    |    189 |
| m    |    666 |
| thy  |    166 |
| yyy  |   1277 |
| zz   |    101 |
| swq  |    122 |
| n    |    111 |
| g    |    145 |
+------+--------+