human
Schema:
Services (Service_ID, Service_Type_Code)
Participants (Participant_ID, Participant_Type_Code, Participant_Details)
Events (Event_ID, Service_ID, Event_Details)
Participants_in_Events (Event_ID, Participant_ID)
Please answer with SQL.
assistant
Sure, I understand.
human
Count the number of participants for each event.
assistant
SELECT event_id , COUNT( * ) FROM Participants_in_Events GROUP by event_id;
human
Among those, which event id has the least participants?
assistant
SELECT event_id FROM Participants_in_Events GROUP by event_id ORDER by COUNT( * ) asc LIMIT 1;
human
What service id is it?
assistant
SELECT service_id FROM Events WHERE event_id = ( SELECT event_id FROM Participants_in_Events GROUP by event_id ORDER by COUNT( * ) asc LIMIT 1 ) ;