select *,(select count(distinct CONVERT(varchar(10), EventTime, 111)) from busi_waybillstatus where waybillid=a.subwaybillid and eventdesc like '%留仓%') as lcs,(select count(distinct CONVERT(varchar(10), EventTime, 111)) from busi_waybillstatus wher...
显示全部select *
,(select count(distinct CONVERT(varchar(10), EventTime, 111)) from busi_waybillstatus where waybillid=a.subwaybillid and eventdesc like '%留仓%') as lcs
,(select count(distinct CONVERT(varchar(10), EventTime, 111)) from busi_waybillstatus where waybillid=a.subwaybillid and eventdesc like '货件从%出库发往派送点%') as cks
,(select top 1 eventdesc from busi_waybillstatus where waybillid=a.subwaybillid and eventdesc like '%留仓%' order by OpTime desc) as lcyy
from BUSI_rukuSubWayBill a left join busi_waybill b on b.waybillid=a.waybillid where a.OpOrgId in (select orgid from bas_org where orgid='5780' or HighOrgId='5780')
and a.optime between '2011-01-01 00:00:00' and '2015-03-03 23:59:59'
这个查询很慢 求大神优化 非常感谢
收起