标签:font receive where com ddc null count 临时表 and
WITH WOTotal AS ( SELECT sysuser.REALNAME,count(1) AS TotalCount FROM WO_OperaionWorkOrderBills owobill WITH(nolock) LEFT JOIN SYS_USER sysuser WITH(NOLOCK) ON sysuser.USERID=owobill.OWOReceiver WHERE sysuser.REALNAME IS NOT NULL and OWOState!=‘OWO_Completed‘ GROUP BY sysuser.REALNAME ), WOAdd AS ( SELECT sysuser.REALNAME,count(1) AS AddCount FROM WO_OperaionWorkOrderBills owobill WITH(nolock) LEFT JOIN SYS_USER sysuser WITH(NOLOCK) ON sysuser.USERID=owobill.OWOReceiver WHERE sysuser.REALNAME IS NOT NULL and OWOState=‘OWO_Add‘ GROUP BY sysuser.REALNAME ), WODispatched AS ( SELECT sysuser.REALNAME,count(1) AS DispatchedCount FROM WO_OperaionWorkOrderBills owobill WITH(nolock) LEFT JOIN SYS_USER sysuser WITH(NOLOCK) ON sysuser.USERID=owobill.OWOReceiver WHERE sysuser.REALNAME IS NOT NULL and OWOState=‘OWO_Dispatched‘ GROUP BY sysuser.REALNAME ) SELECT TOP 10 ‘1‘ as time_sec, WOTotal.RealName as metric ,TotalCount as value,isnull(AddCount,0) AS 新建,isnull(DispatchedCount,0) 派单 FROM WOTotal LEFT JOIN WOAdd ON WOTotal.RealName=WOAdd.RealName LEFT JOIN WODispatched ON WOTotal.RealName=WODispatched.RealName ORDER BY TotalCount desc
标签:font receive where com ddc null count 临时表 and
原文地址:https://www.cnblogs.com/gao109214/p/11635712.html