SqlServer怎么把查询出来的结果整合集为一行?
代码如下:SELECTCOMPANY_ID,CASEPOST_TYPEWHEN'114801'THENCOUNT(*)ENDMANAGER_COUNT,CASEPOST_...
代码如下:
SELECT COMPANY_ID,
CASE POST_TYPE WHEN '114801' THEN COUNT(*) END MANAGER_COUNT,
CASE POST_TYPE WHEN '114802' THEN COUNT(*) END CREDIT_COUNT,
CASE WHEN ISNULL(POST_TYPE,'') NOT IN ('114801','114802') THEN COUNT(*) END ELSE_COUNT
FROM T_M_MANAGERS WHERE COMPANY_ID =18 GROUP BY COMPANY_ID,POST_TYPE
目的:如上图,怎么把第二第三行的6,10整合到第一行里面对应的字段里面
跪求大神!
解决后再追加! 展开
SELECT COMPANY_ID,
CASE POST_TYPE WHEN '114801' THEN COUNT(*) END MANAGER_COUNT,
CASE POST_TYPE WHEN '114802' THEN COUNT(*) END CREDIT_COUNT,
CASE WHEN ISNULL(POST_TYPE,'') NOT IN ('114801','114802') THEN COUNT(*) END ELSE_COUNT
FROM T_M_MANAGERS WHERE COMPANY_ID =18 GROUP BY COMPANY_ID,POST_TYPE
目的:如上图,怎么把第二第三行的6,10整合到第一行里面对应的字段里面
跪求大神!
解决后再追加! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询