case语句,THEN子句错误

时间:2016-06-24 14:49:43

标签: sql cognos

CASE 
WHEN ([PPM 360 View].[Project Data Lite].[Last Review Date] between add_months(trunc (current_date),-6) and current_date) 
    THEN 'Reviewed Within Last 6 Months'
WHEN ([PPM 360 View].[Project Data Lite].[Last Review Date] between add_months(trunc (current_date),-6)-1 and add_months(trunc (current_date),-12)) 
    THEN '7-12 Months Past Due'
WHEN ([PPM 360 View].[Project Data Lite].[Last Review Date] < add_months(trunc (current_date),-12)) 
    THEN 'More Than 12 Months Past Due'
WHEN ([PPM 360 View].[Project Data Lite].[Last Review Date] is null) 
    THEN 'Not Reviewed'
END

....包含'7-12 Months Past Due'的第3个THEN语句将无法正确显示在我正在相应列表的列中创建或填充的堆积条形图的图例中。有什么想法吗?

我在ELSE语句中放置了相同的文字但它出现了,但我宁愿不必这样做。感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我认为第一个add_months()有一个括号问题,因为你之后减去1并且它不是计算的一部分。有没有理由你不只是从7开始减去?