我试图根据用户的输入(SSRS)做一个简单的select语句。救命!
select * from Table1
WHERE
Case when @x = 'Yes' then (select * from Table1 where [Column1] < 0) end;
case when @x = 'No' then (select * from Table1 where [Column1] > 0) end;
提前谢谢
KJ
答案 0 :(得分:3)
应该像
一样简单select * from Table1
WHERE
(@x = 'Yes' AND [Column1] < 0)
OR
(@x = 'No' AND [Column1] > 0);
顺便说一句,SELECT *
编码非常糟糕,你真的应该指定你要返回的每一列。