Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Kein korrektes COUNT() in MySQL-Abfrage (früher geändert)

Versuchen Sie Folgendes:

SELECT 
    sch.id,
    SUM(IF(app.status = 'completed' , 1, 0)) 
FROM 
    com_event_schedules sch
INNER JOIN  com_event_schedules_com_appointment_c rel 
    ON rel.com_event_schedules_com_appointmentcom_event_schedules_ida = sch.id 
INNER JOIN com_appointment app
    ON rel.com_event_schedules_com_appointmentcom_appointment_idb = app.id 
GROUP BY
    sch.id
HAVING
    COUNT(*) > 1