fix: fix sqlness test error about double precision (#7476)

* fix: fix sqlness test error about double precision

Signed-off-by: StandingMan <jmtangcs@gmail.com>

* fix: use round method to truncate the result

Signed-off-by: StandingMan <jmtangcs@gmail.com>

---------

Signed-off-by: StandingMan <jmtangcs@gmail.com>
This commit is contained in:
Alan Tang
2025-12-31 12:55:22 +08:00
committed by GitHub
parent 83932c8c9e
commit 8a07dbf605
2 changed files with 3 additions and 3 deletions

View File

@@ -96,7 +96,7 @@ FROM (
s."location",
COUNT(DISTINCT s.sensor_id) as sensor_count,
COUNT(r.reading_id) / COUNT(DISTINCT s.sensor_id) as avg_readings_per_sensor,
AVG(r."value") as location_avg_value
ROUND(AVG(r."value"), 6) as location_avg_value
FROM sensors s
INNER JOIN readings r ON s.sensor_id = r.sensor_id
GROUP BY s."location"
@@ -107,7 +107,7 @@ ORDER BY location_summary.location_avg_value DESC;
| location | sensor_count | avg_readings_per_sensor | location_avg_value |
+----------+--------------+-------------------------+--------------------+
| Room B | 2 | 2 | 35.88 |
| Room A | 2 | 2 | 31.880000000000003 |
| Room A | 2 | 2 | 31.88 |
+----------+--------------+-------------------------+--------------------+
-- Join with aggregated conditions

View File

@@ -62,7 +62,7 @@ FROM (
s."location",
COUNT(DISTINCT s.sensor_id) as sensor_count,
COUNT(r.reading_id) / COUNT(DISTINCT s.sensor_id) as avg_readings_per_sensor,
AVG(r."value") as location_avg_value
ROUND(AVG(r."value"), 6) as location_avg_value
FROM sensors s
INNER JOIN readings r ON s.sensor_id = r.sensor_id
GROUP BY s."location"