SELECT * FROM (SELECT SAVE_DATE,CARD_TYPE,TOTAL_COUNT FROM t_body_card) PIVOT(SUM(TOTAL_COUNT) FOR CARD_TYPE IN ('普通证' AS PUTONGZHENG,'快证' AS KUAIZHENG,'省内异地快速通道邮' AS YIDIKSYOU,'省内异地快速通道
普' AS YIDIKSPU,'省内异地邮' AS YIDIYOU,'省内异地普' AS YIDIPU,'军人证' AS JUNRENZHENG,'快速通道普' AS KSPU,'快速通道邮' AS KSYOU,'邮寄证' AS YOUJIZHENG,'全国证' AS QUANGUOZHENG))),
t_active_count
AS(
SELECT SAVE_DATE,SUM(IS_ACTIVE)ACTIVE_COUNT FROM t_body_card GROUP BY SAVE_DATE