SQL中A与B同时满足条件的存储过程怎么写

A是个Bit字段,B是数字,当A为true与B小于2时,返回1,其余结果返回0,该怎样写这个存储过程呢?假设A与B全在表C中。
用C#就是
if(A==TRUE&&B<2)
return 1
else
retrun 0
这个用存储过程怎么写?作业要用,明天要交,在线等

第1个回答  2013-04-27
一条SQL语句就行了

select COL1*COL2 from (select (case when A = 'true' then 1 else 0 end) as COL1,(case when B < 2 then 1 else 0 end) as COL2 from C) as t
第2个回答  2013-04-27
if c.a=true and c.b <2 then
select 1;
else select 0;追问

可以写全吗 从create proc Getresult开始 立刻采纳 O(∩_∩)O谢谢

追答

create proc Getresult
as
select (case when c.a=ture and c.b<2 then '1' else '0') from C;

追问

我去验证一下 ==哈

本回答被提问者采纳
相似回答