因此,经过一些故障排除后,我能够通过使用 group by 子句和聚合表甚至添加额外的标签来获得我正在寻找的结果。我不确定它是最优雅的解决方案,但它对我有用:)
SELECT
ts "Timestamp",
sum(case when name = '40FQ8.MV2' then max else null end) "40FQ8.MV2",
sum(case when name = '40FQ431.MV2' then max else null end) "40FQ431.MV2",
sum(case when name = '40FQ1103.MV2' then max else null end) "40FQ1103.MV2",
sum(case when name = '40R1-1_MS.PV' then max else null end) "40R1-1_MS.PV",
sum(case when name = '40R1-2_MS.PV' then max else null end) "40R1-2_MS.PV",
sum(case when name = '40R1-3MS.PV' then max else null end) "40R1-3MS.PV",
sum(case when name = '40R1-1PROG.MV2' then max else null end) "40R1-1PROG.MV2",
sum(case when name = '40R1-2PROG.MV2' then max else null end) "40R1-2PROG.MV2",
sum(case when name = '40R1-3PROG.MV2' then max else null end) "40R1-3PROG.MV2"
FROM aggregates
WHERE
( name = '40FQ8.MV2' OR
name = '40FQ431.MV2' OR
name = '40FQ1103.MV2' OR
name = '40R1-1_MS.PV' OR
name = '40R1-2_MS.PV' OR
name = '40R1-3MS.PV' OR
name = '40R1-1PROG.MV2' OR
name = '40R1-2PROG.MV2' OR
name = '40R1-3PROG.MV2' )
and ts between (getdbtime - 14000) and (getdbtime)
GROUP BY ts
ORDER BY ts
输出:
Timestamp 40FQ8.MV2 40FQ431.MV2 40FQ1103.MV2 40R1-1_MS.PV 40R1-2_MS.PV 40R1-3MS.PV 40R1-1PROG.MV2 40R1-2PROG.MV2 40R1-3PROG.MV2
-------------------- -------------- -------------- -------------- -------------- -------------- -------------- -------------- -------------- --------------
14-JUN-21 17:04:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:05:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:06:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:07:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:08:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:09:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:10:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:11:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:12:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:13:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:14:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:15:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:16:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:17:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:18:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:19:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:20:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:21:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:22:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:23:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:24:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:25:34.8 4275 4370 4540 6 3 3 30 0 0
14-JUN-21 17:26:34.8 4275 4370 4540 6 3 3 30 0 0