This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT COALESCE(hmr.datetime_heat_meter, hmr.timestamp_utc) AS timestamp_utc, | |
| hm.pod_id, | |
| hmr.energy, | |
| hmr.flow, | |
| hmr.power, | |
| hmr.forward_temperature, | |
| hmr.return_temperature, | |
| hmr.pressure, | |
| COALESCE(hmr.volume, 0.0::double precision) AS volume, | |
| NULL::real AS pressure2 | |
| FROM heat_meter_reading hmr | |
| JOIN heat_meter hm ON hm.serial_number = hmr.serial_from_message | |
| WHERE COALESCE(hmr.datetime_heat_meter, hmr.timestamp_utc) IS NOT NULL | |
| UNION ALL | |
| SELECT modbus_reading.timestamp_utc, | |
| modbus_reading.pod_id, | |
| modbus_reading.energy, | |
| modbus_reading.flow, | |
| modbus_reading.power, | |
| modbus_reading.flow_temperature AS forward_temperature, | |
| modbus_reading.return_temperature, | |
| modbus_reading.flow_pressure AS pressure, | |
| 0.0::double precision AS volume, | |
| modbus_reading.return_pressure AS pressure2 | |
| FROM modbus_reading | |
| ) | |
| SELECT readings.timestamp_utc, | |
| readings.energy, | |
| readings.flow, | |
| readings.power, | |
| readings.forward_temperature, | |
| readings.return_temperature, | |
| readings.pressure, | |
| readings.pod_id, | |
| readings.volume, | |
| readings.pressure2 | |
| FROM readings | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment