Order by day_of_week in MySQL

后端 未结 10 2159
一向
一向 2020-12-14 04:15

How can I order the mysql result by varchar column that contains day of week name?

Note that MONDAY should goes first, not SUNDAY.

10条回答
  •  情书的邮戳
    2020-12-14 05:06

    If you try this, it should work:

    SELECT ename, TO_CHAR(hiredate, 'fmDay') as "Day" 
    FROM my_table
    ORDER BY MOD(TO_CHAR(hiredate, 'D') + 5, 7)
    

提交回复
热议问题