SQL-004检查各门店最后未交班日期及人员

/* Formatted on 2020/12/08 18:04:07 (QP5 v5.326) */
SELECT temp.DCLIENTDATE     AS 最后未交班日期,
       temp.VSITENAME       AS 对应店铺名称,
       temp.USER_NAME       AS 公司收银员,
       temp.USER_CODE       AS NC用户名
  FROM (  SELECT RH.DCLIENTDATE
                     AS DCLIENTDATE,
                 RS.VSITENAME
                     AS vsitename,
                 SU.USER_NAME
                     AS user_name,
                 su.USER_CODE
                     AS user_code,
                 ROW_NUMBER ()
                     OVER (PARTITION BY su.USER_CODE ORDER BY rh.ts DESC)
                     AS row_flg
            FROM RMB_HANDOVER rh
                 INNER JOIN rmb_site rs ON RH.CSITEID = RS.CSITEID
                 INNER JOIN sm_user su ON RH.COPERATORID = SU.CUSERID
           WHERE     (dclientdate BETWEEN '2020-06-01' AND '2020-11-30')
                 AND (rh.bisend IS NULL OR rh.bisend <> 'Y')
        ORDER BY rs.vsitename, user_code) temp
 WHERE row_flg = 1

 

posted @ 2020-12-08 18:05  悠灵  阅读(71)  评论(0编辑  收藏  举报