Orace之 case when 统计

SELECT * FROM    DCHN_TEAM_GROUP_RELATION T ;


Orace之 case when 统计_第1张图片

SELECT T.CITY_NAME,
       T.TEAM_NAME,
       T.TEAM_ID,
       SUM(CASE WHEN TYPE = 1 THEN 1 ELSE 0 END),
       SUM(CASE WHEN TYPE = 2 THEN 1 ELSE 0 END )
  FROM DCHN_TEAM_GROUP_RELATION T
 GROUP BY T.CITY_NAME, T.TEAM_NAME, T.TEAM_ID;


Orace之 case when 统计_第2张图片



你可能感兴趣的:(oracle)