Today I have been faced on situation where I need to display a list of users ordered by their name and their level. My table looks like below
id | first_name | last_nae | level |
1 | Muhammad | Salah | player |
2 | Joko | Tole | admin |
3 | Cristioano | Ronaldo | player |
4 | Zlatan | Ibrahimovic | player |
5 | Jose | Mourinho | coach |
6 | Mesut | Ozil | player |
7 | Pep | Guardiola | coach |
8 | Eden | Hazard | player |
9 | Petr | Cech | assistant manager |
My task is to show the table sorted by name, but give a priority order as: admin, coach, assistant manager, player.
You know we just can not order by level column
since the result will sorted alphabetically.