我想执行以下查询, 当date diff大于1时,如何在when子句中将其添加为diffdate在那里不可用。
select
CASE (
SELECT DATEDIFF('2014-11-30','2015-11-29') AS DiffDate
)
WHEN 1 THEN "1 Day"
WHEN 7 THEN "Week"
WHEN ??? THEN "Yearly"
END;
答案 0 :(得分:2)
使用else
select CASE DATEDIFF('2014-11-30','2015-11-29')
WHEN 1 THEN '1 Day'
WHEN 7 THEN '7 Days'
ELSE 'Yearly'
END;