SQL COUNT GROUP BY 统计问题

chendc 发布于 2016/05/08 13:53
阅读 532
收藏 0

求助:

单个表的count 统计 以及  GROUP BY ;

SELECT COUNT(1) AS ZSL,
       T.FLRJG,
       X.FMC AS FLRJGNAME,
       COUNT(CASE
               WHEN T.FSQXM = '1' THEN
                T.FBH
               ELSE
                ''
             END) AS ZZYC,
       COUNT(CASE
               WHEN T.FSQXM = '2' THEN
                T.FBH
               ELSE
                ''
             END) AS GXGZYC,
       COUNT(CASE
               WHEN T.FSQXM = '3' THEN
                T.FBH
               ELSE
                ''
             END) AS GZYC
  FROM T_CWGJSQ T
  LEFT JOIN Z_ORGANIZE_T Z
    ON Z.ID = T.FLRJG
  LEFT JOIN T_XZQH X
    ON X.FBH = Z.ORG_AREA_CODE
 WHERE 1 = 1
 GROUP BY T.FLRJG, X.FMC

如何 在这个基础上,添加另外一个表的统计,合并在一块。

两表之间 关联 T.FLRJG。? 求大神!!


加载中
0
新华万千
新华万千
表关系都没有 谁能回答
返回顶部
顶部