首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

这个SQL如何写啊 急

2012-04-11 
这个SQL怎么写啊? 急~!selectdistinctautoId,define2,inventCode,suppCode,printDate,sum(cast(inventNuma

这个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

热点排行