读书人

这个SQL如何写啊 急

发布时间: 2012-04-11 17:42:33 作者: rapoo

这个SQL怎么写啊? 急~!
select distinct autoId,define2,inventCode,suppCode,printDate,
sum(cast(inventNum as float))as num,
case status when inventbarcode in(select inverntbarcode from t_deliveryVouchs) then '已收货待验货 '
when inventbarcode not in(select inverntbarcode from t_deliveryVouchs) then '未收货 ' end
from t_barcode
group by autoId,define2,inventCode,suppCode,printDate,status

[解决办法]
--try
select distinct autoId,define2,inventCode,suppCode,printDate,
sum(cast(inventNum as float))as num,
case status when inventbarcode in(select inverntbarcode from t_deliveryVouchs) then '已收货待验货 ' else '未收货 ' end
from t_barcode
group by autoId,define2,inventCode,suppCode,printDate,status,inventbarcode

[解决办法]

select aa.*,case when inventbarcode in(select inverntbarcode from t_deliveryVouchs) then '已收货待验货 '
when inventbarcode not in(select inverntbarcode from t_deliveryVouchs) then '未收货 ' end xx
from
(select distinct autoId,define2,inventCode,suppCode,printDate,status,
sum(cast(inventNum as float))as num
from t_barcode
group by autoId,define2,inventCode,suppCode,printDate,status
)aa

读书人网 >SQL Server

热点推荐