Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the complete description of the job of a researcher? [/INST]

Output: SELECT role_description FROM Staff_Roles WHERE role_code  =  'researcher';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: When did the first staff for the projects started working? [/INST]

Output: SELECT date_from FROM Project_Staff ORDER BY date_from ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: When did the first staff member start working? [/INST]

Output: SELECT date_from FROM Project_Staff ORDER BY date_from ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: Which project made the most number of outcomes? List the project details and the project id. [/INST]

Output: SELECT T1.project_details ,  T1.project_id FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id  =  T2.project_id GROUP BY T1.project_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the details and id of the project with the most outcomes? [/INST]

Output: SELECT T1.project_details ,  T1.project_id FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id  =  T2.project_id GROUP BY T1.project_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: Which projects have no outcome? List the project details. [/INST]

Output: SELECT project_details FROM Projects WHERE project_id NOT IN ( SELECT project_id FROM Project_outcomes );


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the details of the project with no outcomes? [/INST]

Output: SELECT project_details FROM Projects WHERE project_id NOT IN ( SELECT project_id FROM Project_outcomes );


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: Which organisation hired the most number of research staff? List the organisation id, type and detail. [/INST]

Output: SELECT T1.organisation_id ,  T1.organisation_type ,  T1.organisation_details FROM Organisations AS T1 JOIN Research_Staff AS T2 ON T1.organisation_id  =  T2.employer_organisation_id GROUP BY T1.organisation_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the ids, types, and details of the organization with the most research staff? [/INST]

Output: SELECT T1.organisation_id ,  T1.organisation_type ,  T1.organisation_details FROM Organisations AS T1 JOIN Research_Staff AS T2 ON T1.organisation_id  =  T2.employer_organisation_id GROUP BY T1.organisation_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: Show the role description and the id of the project staff involved in most number of project outcomes? [/INST]

Output: SELECT T1.role_description ,  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;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: For each staff id, what is the description of the role that is involved with the most number of projects? [/INST]

Output: SELECT T1.role_description ,  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;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: Which document type is described with the prefix 'Initial'? [/INST]

Output: SELECT document_type_code FROM Document_Types WHERE document_description LIKE 'Initial%';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the type of the document whose description starts with the word 'Initial'? [/INST]

Output: SELECT document_type_code FROM Document_Types WHERE document_description LIKE 'Initial%';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: For grants with both documents described as 'Regular' and documents described as 'Initial Application', list its start date. [/INST]

Output: SELECT T1.grant_start_date FROM Grants AS T1 JOIN Documents AS T2 ON T1.grant_id  =  T2.grant_id JOIN Document_Types AS T3 ON T2.document_type_code  =  T3.document_type_code WHERE T3.document_description  =  'Regular' INTERSECT SELECT T1.grant_start_date FROM Grants AS T1 JOIN Documents AS T2 ON T1.grant_id  =  T2.grant_id JOIN Document_Types AS T3 ON T2.document_type_code  =  T3.document_type_code WHERE T3.document_description  =  'Initial Application';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: For grants that have descriptions of Regular and Initial Applications, what are their start dates? [/INST]

Output: SELECT T1.grant_start_date FROM Grants AS T1 JOIN Documents AS T2 ON T1.grant_id  =  T2.grant_id JOIN Document_Types AS T3 ON T2.document_type_code  =  T3.document_type_code WHERE T3.document_description  =  'Regular' INTERSECT SELECT T1.grant_start_date FROM Grants AS T1 JOIN Documents AS T2 ON T1.grant_id  =  T2.grant_id JOIN Document_Types AS T3 ON T2.document_type_code  =  T3.document_type_code WHERE T3.document_description  =  'Initial Application';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: How many documents can one grant have at most? List the grant id and number. [/INST]

Output: SELECT grant_id ,  count(*) FROM Documents GROUP BY grant_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: For each grant id, how many documents does it have, and which one has the most? [/INST]

Output: SELECT grant_id ,  count(*) FROM Documents GROUP BY grant_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: Find the organisation type description of the organisation detailed as 'quo'. [/INST]

Output: SELECT T1.organisation_type_description FROM organisation_Types AS T1 JOIN Organisations AS T2 ON T1.organisation_type  =  T2.organisation_type WHERE T2.organisation_details  =  'quo';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the type description of the organization whose detail is listed as 'quo'? [/INST]

Output: SELECT T1.organisation_type_description FROM organisation_Types AS T1 JOIN Organisations AS T2 ON T1.organisation_type  =  T2.organisation_type WHERE T2.organisation_details  =  'quo';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are all the details of the organisations described as 'Sponsor'? Sort the result in an ascending order. [/INST]

Output: SELECT organisation_details FROM Organisations AS T1 JOIN organisation_Types AS T2 ON T1.organisation_type  =  T2.organisation_type WHERE T2.organisation_type_description  =  'Sponsor' ORDER BY organisation_details;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the details of all organizations that are described as Sponsors and sort the results in ascending order? [/INST]

Output: SELECT organisation_details FROM Organisations AS T1 JOIN organisation_Types AS T2 ON T1.organisation_type  =  T2.organisation_type WHERE T2.organisation_type_description  =  'Sponsor' ORDER BY organisation_details;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: How many Patent outcomes are generated from all the projects? [/INST]

Output: SELECT count(*) FROM Project_outcomes WHERE outcome_code  =  'Patent';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: How many patents outcomes were listed for all the projects? [/INST]

Output: SELECT count(*) FROM Project_outcomes WHERE outcome_code  =  'Patent';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: How many project staff worked as leaders or started working before '1989-04-24 23:51:54'? [/INST]

Output: SELECT count(*) FROM Project_Staff WHERE role_code  =  'leader' OR date_from  <  '1989-04-24 23:51:54';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: How many project members were leaders or started working before '1989-04-24 23:51:54'? [/INST]

Output: SELECT count(*) FROM Project_Staff WHERE role_code  =  'leader' OR date_from  <  '1989-04-24 23:51:54';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the last date of the staff leaving the projects? [/INST]

Output: SELECT date_to FROM Project_Staff ORDER BY date_to DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the last date that a staff member left a project? [/INST]

Output: SELECT date_to FROM Project_Staff ORDER BY date_to DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the result description of the project whose detail is 'sint'? [/INST]

Output: SELECT T1.outcome_description FROM Research_outcomes AS T1 JOIN Project_outcomes AS T2 ON T1.outcome_code  =  T2.outcome_code JOIN Projects AS T3 ON T2.project_id  =  T3.project_id WHERE T3.project_details  =  'sint';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the description for the results whose project detail is 'sint'? [/INST]

Output: SELECT T1.outcome_description FROM Research_outcomes AS T1 JOIN Project_outcomes AS T2 ON T1.outcome_code  =  T2.outcome_code JOIN Projects AS T3 ON T2.project_id  =  T3.project_id WHERE T3.project_details  =  'sint';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: List the organisation id with the maximum outcome count, and the count. [/INST]

Output: SELECT T1.organisation_id ,  count(*) FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id  =  T2.project_id GROUP BY T1.organisation_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the id of the organization with the maximum number of outcomes and how many outcomes are there? [/INST]

Output: SELECT T1.organisation_id ,  count(*) FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id  =  T2.project_id GROUP BY T1.organisation_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: List the project details of the projects launched by the organisation [/INST]

Output: SELECT project_details FROM Projects WHERE organisation_id IN ( SELECT organisation_id FROM Projects GROUP BY organisation_id ORDER BY count(*) DESC LIMIT 1 );


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the details for the projects which were launched by the organization with the most projects? [/INST]

Output: SELECT project_details FROM Projects WHERE organisation_id IN ( SELECT organisation_id FROM Projects GROUP BY organisation_id ORDER BY count(*) DESC LIMIT 1 );


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: List the research staff details, and order in ascending order. [/INST]

Output: SELECT staff_details FROM Research_Staff ORDER BY staff_details ASC;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What details are there on the research staff? List the result in ascending alphabetical order. [/INST]

Output: SELECT staff_details FROM Research_Staff ORDER BY staff_details ASC;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: How many tasks are there in total? [/INST]

Output: SELECT count(*) FROM Tasks;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: How many tasks are there? [/INST]

Output: SELECT count(*) FROM Tasks;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: How many tasks does each project have? List the task count and the project detail. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: For each project id, how many tasks are there? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the staff roles of the staff who [/INST]

Output: SELECT role_code FROM Project_Staff WHERE date_from  >  '2003-04-19 15:06:20' AND date_to  <  '2016-03-15 00:33:18';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What roles did staff members play between '2003-04-19 15:06:20' and '2016-03-15 00:33:18'? [/INST]

Output: SELECT role_code FROM Project_Staff WHERE date_from  >  '2003-04-19 15:06:20' AND date_to  <  '2016-03-15 00:33:18';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the descriptions of all the project outcomes? [/INST]

Output: SELECT T1.outcome_description FROM Research_outcomes AS T1 JOIN Project_outcomes AS T2 ON T1.outcome_code  =  T2.outcome_code;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: List the description of the outcomes for all projects. [/INST]

Output: SELECT T1.outcome_description FROM Research_outcomes AS T1 JOIN Project_outcomes AS T2 ON T1.outcome_code  =  T2.outcome_code;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: Which role is most common for the staff? [/INST]

Output: SELECT role_code FROM Project_Staff GROUP BY role_code ORDER BY count(*) DESC LIMIT 1;