SELECT
DEVICE_NO,
MAX(CASE PHASE WHEN 1 THEN U ELSE 0 END) AS 'UA',
MAX(CASE PHASE WHEN 2 THEN U ELSE 0 END) AS 'UB',
MAX(CASE PHASE WHEN 3 THEN U ELSE 0 END) AS 'UC'
FROM
T_V_I_RECORD
GROUP BY
DEVICE_NO,SEGMENTID,INSERT_TIME
讲解:一张表 只有相位1 2 3代表ABC项,U代表电压值。
需要转三列如果一行转三列,可按上述语句操作,group by 后要能确定唯一键