to
WITH TEMP AS (SELECT
DECODE(MAX(DECODE(T.T_YZ_NAME, '流量', T.T_YZ_VALUE)),'','-',MAX(DECODE(T.T_YZ_NAME, '流量', T.T_YZ_VALUE))) AS 流量,
DECODE(MAX(DECODE(T.T_YZ_NAME, 'PH 值', T.T_YZ_VALUE)),'','-',MAX(DECODE(T.T_YZ_NAME, 'PH 值', T.T_YZ_VALUE)))AS PH值,
DECODE(MAX(DECODE(T.T_YZ_NAME, 'COD', T.T_YZ_VALUE)),'','-',MAX(DECODE(T.T_YZ_NAME, 'COD', T.T_YZ_VALUE))) AS COD,
DECODE(MAX(DECODE(T.T_YZ_NAME, '氨氮', T.T_YZ_VALUE)),'','-',MAX(DECODE(T.T_YZ_NAME, '氨氮', T.T_YZ_VALUE)))AS 氨氮,
DECODE(MAX(DECODE(T.T_YZ_NAME, '总磷', T.T_YZ_VALUE)),'','-',MAX(DECODE(T.T_YZ_NAME, '总磷', T.T_YZ_VALUE)))AS 总磷,
DECODE(MAX(DECODE(T.T_YZ_NAME, '总氮', T.T_YZ_VALUE)),'','-',MAX(DECODE(T.T_YZ_NAME, '总氮', T.T_YZ_VALUE))) AS 总氮
FROM ZTS_JKDXX J
LEFT JOIN ZTS_PFKJBXX P
ON P.GUID = J.T_PWK_ID
LEFT JOIN (SELECT QY.GUID, QY.T_QYJC, QY.T_YQLX, QY.T_GZCD
FROM ZTS_QYJBXX QY
WHERE QY.T_SHZT IN ( '待入网', '已入网')) QY
ON P.T_QY_ID = QY.GUID
LEFT JOIN ZTS_FSYZSJJL T
ON QY.GUID = T.T_QYID
AND T.T_JKDID = J.GUID
WHERE J.GUID = '89AA0ADCE92D4741962EB17DE9CE1AB5'
) SELECT YZNAME,YZVALUE FROM TEMP UNPIVOT
(YZVALUE FOR YZNAME IN(流量,PH值,COD,氨氮,总磷,总氮))T;