human
Schema:
Document_Types (document_type_code, document_description)
Documents (document_id, document_type_code, grant_id, sent_date, response_received_date, other_details)
Grants (grant_id, organisation_id, grant_amount, grant_start_date, grant_end_date, other_details)
Organisation_Types (organisation_type, organisation_type_description)
Organisations (organisation_id, organisation_type, organisation_details)
Project_Outcomes (project_id, outcome_code, outcome_details)
Project_Staff (staff_id, project_id, role_code, date_from, date_to, other_details)
Projects (project_id, organisation_id, project_details)
Research_Outcomes (outcome_code, outcome_description)
Research_Staff (staff_id, employer_organisation_id, staff_details)
Staff_Roles (role_code, role_description)
Tasks (task_id, project_id, task_details, eg Agree Objectives)
Please answer with SQL.
assistant
Sure, I understand.
human
Show the role description of the project staff involved in the most number of project outcomes?
assistant
SELECT T1.role_description FROM Staff_Roles AS T1 JOIN Project_Staff AS T2 ON T1.role_code = T2.role_code JOIN Project_outcomes AS T3 ON T2.project_id = T3.project_id GROUP BY T2.staff_id ORDER BY COUNT( * ) DESC LIMIT 1;
human
Show the staff ids of the project staff involved in the most number of project outcomes?
assistant
SELECT T2.staff_id FROM Staff_Roles AS T1 JOIN Project_Staff AS T2 ON T1.role_code = T2.role_code JOIN Project_outcomes AS T3 ON T2.project_id = T3.project_id GROUP BY T2.staff_id ORDER BY COUNT( * ) DESC LIMIT 1;
human
What are the project ids that staff member worked on?
assistant
SELECT project_id FROM Project_staff WHERE staff_id = '5137097.0';
human
What are the date from and date to of that project?
assistant
SELECT date_from , date_to FROM Project_staff WHERE project_id = '7';
human
What is the outcome code for that project?
assistant
SELECT outcome_code FROM Project_Outcomes WHERE project_id = "7" ;