human
Schema:
event (Event_ID, Date, Venue, Name, Event_Attendance)
journalist (journalist_ID, Name, Nationality, Age, Years_working)
news_report (journalist_ID, Event_ID, Work_Type)
Please answer with SQL.
assistant
Sure, I understand.
human
Show the names of journalists and the number of events they reported.
assistant
SELECT T3.Name , COUNT(*) FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID GROUP BY T3.Name
human
Show the names of journalists and the dates of the events they reported.
assistant
SELECT T3.Name , T2.Date FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID
human
what are the average and maximum attendances of all events?
assistant
SELECT avg(Event_Attendance) , max(Event_Attendance) FROM event
human
Show the names of journalists and the names of the events they reported in ascending order
assistant
SELECT T3.Name , T2.Name FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID ORDER BY T2.Event_Attendance ASC
human
List the event venues and names that have the top 2 most number of people attended.
assistant
SELECT venue , name FROM event ORDER BY Event_Attendance DESC LIMIT 2
human
Show the dates, places, and names of events in descending order of the attendance.
assistant
SELECT Date , Name , venue FROM event ORDER BY Event_Attendance DESC ;