if select count(*) from tablename > 0
print 'test'======
select count(*) from tablename的值是5,但是和0比较报错,如何在sql语句里面写这样的比较?在线等,马上结贴!
print 'test'======
select count(*) from tablename的值是5,但是和0比较报错,如何在sql语句里面写这样的比较?在线等,马上结贴!
print 'test'
print 'test'
print 'test'
在IF后面需要加括号 把它包起来,
如果是单值 则不需要
if (select count(*)from tablename) > 0
insert into @a
select
'200805',30 union all select
'200805',40 union all select
'200805',50 union all select
'200805',20 union all select
'200806',250 union all select
'200806',200 union all select
'200806',310 union all select
'200806',100 union all select
--'200806',300 union all select
'200806',130;select (select count(*) from @a where rq=t.rq and ddsj<=t.ddsj)as num ,*
into #t from @a t order by ddsjselect
t.*
from
#t t ,
(
select
(min(num)+max(num))/2 num,
ceiling((min(num)+max(num))*1.0/2)num1,rq
from
#t
group by rq)as t1 where (t.num=t1.num or t.num=t1.num1) and t.rq=t1.rqnum rq ddsj
----------- -------- -----------
2 200805 30
3 200805 40
3 200806 200(所影响的行数为 3 行)