我有一个表"hallowelt“,它包含15列,其中一列的名称是"month”。如何创建表"hallowelt“的视图,其中月份通过CASE语句适当地转换为新的列季节,分为春、夏、秋、冬。
示例代码:
create view hallo_welt
SELECT month, as 'season'
CASE
when month=3 or month<=5 then 'Frühling'
when month=6 or month<=8 then 'sommer'
when month=9 or month<=11 then 'Herbst'
when month=12 or month<=2 then 'winter'
else ''
END
from hallowelt;发布于 2021-02-14 12:57:47
你可能想要像这样的东西
create view hallo_welt
SELECT
month,
CASE
when month in (3,4,5) then 'Frühling'
when month in (6,7,8) then 'sommer'
when month in (9,10,11) then 'Herbst'
when month in (12,1,2) then 'winter'
else null
END season
from hallowelt;https://stackoverflow.com/questions/66191485
复制相似问题