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
List the names of journalists in ascending order of years working.
assistant
SELECT Name FROM journalist ORDER BY Years_working ASC
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
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
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 that have reported more than one event.
assistant
SELECT T3.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 GROUP BY T3.Name HAVING COUNT(*) > 1
human
List the names of journalists who have not reported any event.
assistant
SELECT Name FROM journalist WHERE journalist_ID NOT IN ( SELECT journalist_ID FROM news_report ) ;