zoukankan      html  css  js  c++  java
  • 第一次用临时表的感受:

    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
  • 相关阅读:
    如何添加动画效果
    iQuery高版本不兼容旋转木马插件问题
    splice方法可以实现增删改功能
    swiper.js实现轮播图效果
    MySQL | 操作表数据
    MySQL | 高级查询
    MySQL | 基本查询
    MySQL | 表函数
    MySQL | 表约束
    MySQL | 操作表
  • 原文地址:https://www.cnblogs.com/gao109214/p/11635712.html
Copyright © 2011-2022 走看看