当前位置: 代码迷 >> Sql Server >> 这个SQL如何写啊 急
  详细解决方案

这个SQL如何写啊 急

热度:81   发布时间:2016-04-27 19:35:42.0
这个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
  相关解决方案