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
What are the descriptions of all the project outcomes?
assistant
SELECT T1.outcome_description FROM Research_outcomes AS T1 JOIN Project_outcomes AS T2 ON T1.outcome_code = T2.outcome_code
human
How many kinds of roles are there for the staff?
assistant
SELECT count(DISTINCT role_code) FROM Project_Staff
human
How many project staff worked as leaders or started working before '1989-04-24 23:51:54'?
assistant
SELECT count(*) FROM Project_Staff WHERE role_code = 'leader' OR date_from < '1989-04-24 23:51:54'
human
What are the task details, task id and project id for the projects which are detailed as 'omnis' or have more than 2 outcomes?
assistant
SELECT T1.task_details , T1.task_id , T2.project_id FROM Tasks AS T1 JOIN Projects AS T2 ON T1.project_id = T2.project_id WHERE T2.project_details = 'omnis' UNION SELECT T1.task_details , T1.task_id , T2.project_id FROM Tasks AS T1 JOIN Projects AS T2 ON T1.project_id = T2.project_id JOIN Project_outcomes AS T3 ON T2.project_id = T3.project_id GROUP BY T2.project_id HAVING count(*) > 2
human
How many tasks does each project have? List the task count and the project detail.
assistant
SELECT count(*) , T1.project_details FROM Projects AS T1 JOIN Tasks AS T2 ON T1.project_id = T2.project_id GROUP BY T1.project_id
human
How many tasks are there?
assistant
SELECT COUNT( * ) FROM Tasks ;