Fix: Fix SQL GROUP BY error in daily/hourly summary aggregation - Use COALESCE in GROUP BY to handle NULL tariff amounts - Remove invalid is_active check on tariffs table

This commit is contained in:
mwpn
2025-12-17 13:32:31 +07:00
parent 220b554a17
commit 533c22d3af
2 changed files with 2 additions and 3 deletions

View File

@@ -58,7 +58,7 @@ class DailySummaryService
e.location_code,
e.gate_code,
e.category,
t.amount
COALESCE(t.amount, 0)
";
$stmt = $this->db->prepare($sql);

View File

@@ -54,7 +54,6 @@ class HourlySummaryService
LEFT JOIN tariffs t ON e.location_code = t.location_code
AND e.gate_code = t.gate_code
AND e.category = t.category
AND t.is_active = 1
WHERE DATE(e.event_time) = ?
GROUP BY
DATE(e.event_time),
@@ -62,7 +61,7 @@ class HourlySummaryService
e.location_code,
e.gate_code,
e.category,
t.amount
COALESCE(t.amount, 0)
";
$stmt = $this->db->prepare($sql);