我希望我的sql查询在公司拥有超过4500名员工时停止使用查询。但是当我低于4500时,我没有得到正确的价值,(价格是 45 $ /员工)
{CASE WHEN ([company].[nremployees]* 45) <4500
THEN 4500
ELSE
CASE WHEN ([company].[nremployees]* 45) > 4500 THEN
[company].[pricespecial] else
0 END END else [company].[servicebill] end}
答案 0 :(得分:2)
END
太多了,你过于复杂了。尝试使用简化版
CASE
WHEN [company].[nremployees] < 100 THEN 4500
WHEN [company].[nremployees] > 100 THEN [company].[pricespecial]
ELSE [company].[servicebill] /* or 0, can't understand from your query */
END