From 1ffdda5ffe188c20f0eb316ef617a0e6a4e6955b Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 16 Jul 2026 17:30:52 +0800 Subject: [PATCH] fix(billing): add acc_date to aggregate query for sqlor ORDER BY sqlor wraps every sqlExe with row_number() over(order by acc_date desc). Aggregate queries without acc_date in SELECT fail with: Unknown column 'acc_date' in 'ORDER BY' Fix: add min(acc_date) as acc_date to satisfy sqlor wrapper. --- wwwroot/billing.dspy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wwwroot/billing.dspy b/wwwroot/billing.dspy index 72d25f3..0d6cfea 100644 --- a/wwwroot/billing.dspy +++ b/wwwroot/billing.dspy @@ -32,7 +32,8 @@ where a.orgid = ${orgid}$ stats_sql = """select count(*) as total_count, coalesce(sum(case when d.acc_dir = '1' then d.amount else 0 end), 0) as debit_sum, - coalesce(sum(case when d.acc_dir = '0' then d.amount else 0 end), 0) as credit_sum + coalesce(sum(case when d.acc_dir = '0' then d.amount else 0 end), 0) as credit_sum, + min(d.acc_date) as acc_date from acc_detail d join account a on d.accountid = a.id COLLATE utf8mb4_unicode_ci where a.orgid = ${orgid}$