mysql – 将值映射到文本“on fly”
作者:互联网
我有下表:
store | dow | turnover
------+-----+-----------
1 | 1 | Eu59.426,00
1 | 2 | Eu33.074,00
1 | 5 | Eu38.855,00
1 | 6 | Eu64.431,00
请告诉我如何将星期几表示为星期日,星期一等,以便我不必使用此映射创建新表.
解决方法:
试试这个:
SELECT store, (CASE dow WHEN 1 THEN 'Sunday'
WHEN 2 THEN 'Monday'
WHEN 3 THEN 'Tuesday'
WHEN 4 THEN 'Wednesday'
WHEN 5 THEN 'Thursday'
WHEN 6 THEN 'Friday'
WHEN 7 THEN 'Saturday'
END), turnover
FROM tableA;
标签:dayofweek,sql,mysql,datetime,select 来源: https://codeday.me/bug/20190825/1717867.html