SELECT * FROM O_PLATI_DAUNE
WHERE
LUNA LIKE
CASE
WHEN LUNA = '7' THEN SUMA ='363623.72'
WHEN LUNA = '8' THEN SUMA ='825159.25'
WHEN LUNA = '9' THEN SUMA ='182730.99'
WHEN LUNA = '10' THEN SUMA ='361722.74'
WHEN LUNA = '11' THEN SUMA ='1787574.67'
WHEN LUNA = '12' THEN SUMA ='3605005.68'
ELSE 'N/A'
END
我不知道为什么它不起作用,请有人帮助我!
非常感谢。
答案 0 :(得分:1)
您是否正在尝试执行以下操作:
SELECT id,LUNA,CASE
WHEN LUNA = '7' THEN '363623.72'
WHEN LUNA = '8' THEN '825159.25'
WHEN LUNA = '9' THEN '182730.99'
WHEN LUNA = '10' THEN '361722.74'
WHEN LUNA = '11' THEN '1787574.67'
WHEN LUNA = '12' THEN '3605005.68'
ELSE 'N/A'
END as SUMA
FROM O_PLATI_DAUNE
答案 1 :(得分:0)
我相信这是针对MySQL的,所以我建议您阅读CASE上的手册:
http://dev.mysql.com/doc/refman/5.1/en/case-statement.html
在页面下方稍微查看一下示例 - 您的案例结构已关闭。
Case语句不能直接在WHERE子句中使用 - 试图找到一个例子,但到目前为止还没有运气。