fix: 医生余号查询按schedule_date分组,避免多日期余号累加

This commit is contained in:
关羽
2026-04-09 09:42:07 +08:00
parent 3a02e327c7
commit 41b1d47bba

View File

@@ -354,6 +354,7 @@
SELECT
p.doctor_id AS doctorId,
p.doctor_name AS doctorName,
p.schedule_date AS scheduleDate,
COALESCE(
SUM(
GREATEST(
@@ -363,6 +364,7 @@
),
0
) AS available,
COUNT(DISTINCT p.id) AS poolCount,
CASE
WHEN MAX(
CASE
@@ -407,8 +409,10 @@
</where>
GROUP BY
p.doctor_id,
p.doctor_name
p.doctor_name,
p.schedule_date
ORDER BY
p.schedule_date ASC,
p.doctor_name ASC
</select>