想查什么?
select count(*) as DResult from Orderdata c,sm_consignd d where c.quantity<d.quantity group by c.pact_no
select count(*) as DResult from Orderdata c,sm_consignd d where c.quantity<d.quantity group by c.pact_no
select c.pact_no,c.quantity as qty1,d.quantity as qty2 ,0 as ddd into #aa
from Orderdata c,sm_consignd d
update #aa set ddd=1 where qty1<qty2
select pact_no,sum(ddd) as DResult
from #aa group by pact_no
when后面不支持运算啊……还有办法么?
select case when exists (
select 1 as DResult from Orderdata c,sm_consignd d
where c.quantity<d.quantity
) then 1
else 0
end as xxx
select Dresult as 1 from Orderdata c,sm_consignd d
where c.quantity<d.quantity
select ……from ……where …… and (这一段啊)