我在一个列中有一些日期数据,我想添加一个新列作为semester:
1-4月是春天
5-8月是夏天
9月至12月是秋季
start date
--------------
'12-JAN-2019'
'28-DEC-2018'
'05-JAN-2019'
'10-JULY-2018'所以我试着:
select id, case(
when extract(month from start_date) between 1 and 4 then 'Spring'
when extract(month from start_date) between 5 and 8 then 'Summer'
else 'Fall'
end)
from table但是oracle显示错误:缺少右括号谁能告诉我为什么和如何修复它?
谢谢!!
发布于 2019-04-16 01:14:57
尝尝这个。
SELECT id,
CASE
WHEN Extract(month FROM start_date) BETWEEN 1 AND 4 THEN 'Spring'
WHEN Extract(month FROM start_date) BETWEEN 5 AND 8 THEN 'Summer'
ELSE 'Fall'
END AS Semester
FROM tablename; 发布于 2019-04-16 01:12:20
select id, (case
when extract(month from start_date) between 1 and 4 then 'Spring'
when extract(month from start_date) between 5 and 8 then 'Summer'
else 'Fall'
end)
from tablehttps://stackoverflow.com/questions/55694037
复制相似问题