---防伪税控数据查询3(行转列)
SELECT MC,
NVL(SMRZ, 0) SMRZ,
NVL(GXRZ, 0) GXRZ,
NVL(BGFX, 0) BGFX,
NVL(WSRZ, 0) WSRZ,
NVL(FPFF, 0) FPFF,
NVL(SKBS, 0) SKBS,
NVL(ZXFX, 0) ZXFX
FROM (SELECT T.MC, T.YWXL_DM, T.YWL
FROM (SELECT B.SWJGMC MC, C.YWXL_DM, A.YWL
FROM GGZJK.XT_FWSK_YWRTJ A,
DM_GY_SWJG B,
GGZJK.DM_GY_YWXL C
WHERE A.SWJG_DM = B.SWJG_DM
AND A.YWXL_DM = C.YWXL_DM
AND A.RQ >= '20190201'
AND A.RQ < '20190227' + 1
AND A.SWJG_DM LIKE '%%'
GROUP BY B.SWJGMC, C.YWXL_DM, A.YWL) T) PIVOT(SUM(YWL) FOR YWXL_DM IN('161001001' SMRZ,
'161001002' GXRZ,
'161001003' BGFX,
'161001004' WSRZ,
'161001005' FPFF,
'161001007' SKBS,
'161001008' ZXFX))
行转列数据
最新推荐文章于 2024-04-06 20:56:42 发布