Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Show the minister who took office after 1961 or before 1959. [/INST]

Output: SELECT minister FROM party WHERE took_office  >  1961 OR took_office  <  1959;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Who are the ministers who took office after 1961 or before 1959? [/INST]

Output: SELECT minister FROM party WHERE took_office  >  1961 OR took_office  <  1959;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Show all ministers who do not belong to Progress Party. [/INST]

Output: SELECT minister FROM party WHERE party_name != 'Progress Party';


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Which ministers are not a part of the Progress Party? [/INST]

Output: SELECT minister FROM party WHERE party_name != 'Progress Party';


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Show all ministers and parties they belong to in descending order of the time they took office. [/INST]

Output: SELECT minister ,  party_name FROM party ORDER BY took_office DESC;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Who are the ministers and what parties do they belong to, listed descending by the times they took office? [/INST]

Output: SELECT minister ,  party_name FROM party ORDER BY took_office DESC;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Return the minister who left office at the latest time. [/INST]

Output: SELECT minister FROM party ORDER BY left_office DESC LIMIT 1;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Which minister left office the latest? [/INST]

Output: SELECT minister FROM party ORDER BY left_office DESC LIMIT 1;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: List member names and their party names. [/INST]

Output: SELECT T1.member_name ,  T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: What are the names of members and their corresponding parties? [/INST]

Output: SELECT T1.member_name ,  T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Show all party names and the number of members in each party. [/INST]

Output: SELECT T2.party_name ,  count(*) FROM Member AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id GROUP BY T1.party_id;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: How many members are in each party? [/INST]

Output: SELECT T2.party_name ,  count(*) FROM Member AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id GROUP BY T1.party_id;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: What is the name of party with most number of members? [/INST]

Output: SELECT T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id GROUP BY T1.party_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Return the name of the party with the most members. [/INST]

Output: SELECT T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id GROUP BY T1.party_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Show all party names and their region names. [/INST]

Output: SELECT T1.party_name ,  T2.region_name FROM party AS T1 JOIN region AS T2 ON T1.region_id  =  T2.region_id;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: What are the names of parties and their respective regions? [/INST]

Output: SELECT T1.party_name ,  T2.region_name FROM party AS T1 JOIN region AS T2 ON T1.region_id  =  T2.region_id;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Show names of parties that does not have any members. [/INST]

Output: SELECT party_name FROM party WHERE party_id NOT IN (SELECT party_id FROM Member);


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: What are the names of parties that have no members? [/INST]

Output: SELECT party_name FROM party WHERE party_id NOT IN (SELECT party_id FROM Member);


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Show the member names which are in both the party with id 3 and the party with id 1. [/INST]

Output: SELECT member_name FROM member WHERE party_id  =  3 INTERSECT SELECT member_name FROM member WHERE party_id  =  1;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Which member names are shared among members in the party with the id 3 and the party with the id 1? [/INST]

Output: SELECT member_name FROM member WHERE party_id  =  3 INTERSECT SELECT member_name FROM member WHERE party_id  =  1;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Show member names that are not in the Progress Party. [/INST]

Output: SELECT T1.member_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id WHERE T2.Party_name != "Progress Party";


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Which member names corresponding to members who are not in the Progress Party? [/INST]

Output: SELECT T1.member_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id WHERE T2.Party_name != "Progress Party";


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: How many party events do we have? [/INST]

Output: SELECT count(*) FROM party_events;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Count the number of party events. [/INST]

Output: SELECT count(*) FROM party_events;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Show party names and the number of events for each party. [/INST]

Output: SELECT T2.party_name ,  count(*) FROM party_events AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id GROUP BY T1.party_id;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

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

Output: SELECT T2.party_name ,  count(*) FROM party_events AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id GROUP BY T1.party_id;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Show all member names who are not in charge of any event. [/INST]

Output: SELECT member_name FROM member EXCEPT SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id  =  T2.member_in_charge_id;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: What are the names of members who are not in charge of any events? [/INST]

Output: SELECT member_name FROM member EXCEPT SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id  =  T2.member_in_charge_id;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: What are the names of parties with at least 2 events? [/INST]

Output: SELECT T2.party_name FROM party_events AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id GROUP BY T1.party_id HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Return the names of parties that have two or more events. [/INST]

Output: SELECT T2.party_name FROM party_events AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id GROUP BY T1.party_id HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: What is the name of member in charge of greatest number of events? [/INST]

Output: SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id  =  T2.member_in_charge_id GROUP BY T2.member_in_charge_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Return the name of the member who is in charge of the most events. [/INST]

Output: SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id  =  T2.member_in_charge_id GROUP BY T2.member_in_charge_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: find the event names that have more than 2 records. [/INST]

Output: SELECT event_name FROM party_events GROUP BY event_name HAVING count(*)  >  2;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Which event names were used more than twice for party events? [/INST]

Output: SELECT event_name FROM party_events GROUP BY event_name HAVING count(*)  >  2;


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: How many Annual Meeting events happened in the United Kingdom region? [/INST]

Output: SELECT count(*) FROM region AS t1 JOIN party AS t2 ON t1.region_id  =  t2.region_id JOIN party_events AS t3 ON t2.party_id  =  t3.party_id WHERE t1.region_name  =  "United Kingdom" AND t3.Event_Name  =  "Annaual Meeting";


Input:
[INST] Here is a database schema:
region :
Region_ID [ INT ] primary_key
Region_name [ TEXT ]
Date [ TEXT ]
Label [ TEXT ]
Format [ TEXT ]
Catalogue [ TEXT ]

party :
Party_ID [ INT ] primary_key
Minister [ TEXT ]
Took_office [ TEXT ]
Left_office [ TEXT ]
Region_ID [ INT ] party.Region_ID = region.Region_ID
Party_name [ TEXT ]

member :
Member_ID [ INT ] primary_key
Member_Name [ TEXT ]
Party_ID [ TEXT ] member.Party_ID = party.Party_ID
In_office [ TEXT ]

party_events :
Event_ID [ INT ] primary_key
Event_Name [ TEXT ]
Party_ID [ INT ] party_events.Party_ID = party.Party_ID
Member_in_charge_ID [ INT ] party_events.Member_in_charge_ID = member.Member_ID

Please write me a SQL statement that answers the following question: Count the number of Annual Meeting events that took place in the region of the United Kingdom. [/INST]

Output: SELECT count(*) FROM region AS t1 JOIN party AS t2 ON t1.region_id  =  t2.region_id JOIN party_events AS t3 ON t2.party_id  =  t3.party_id WHERE t1.region_name  =  "United Kingdom" AND t3.Event_Name  =  "Annaual Meeting";


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

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

Output: SELECT count(*) FROM pilot;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: List the names of pilots in ascending order of rank. [/INST]

Output: SELECT Pilot_name FROM pilot ORDER BY Rank ASC;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: What are the positions and teams of pilots? [/INST]

Output: SELECT POSITION ,  Team FROM pilot;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: List the distinct positions of pilots older than 30. [/INST]

Output: SELECT DISTINCT POSITION FROM pilot WHERE Age  >  30;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: Show the names of pilots from team "Bradley" or "Fordham". [/INST]

Output: SELECT Pilot_name FROM pilot WHERE Team  =  "Bradley" OR Team  =  "Fordham";


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the joined year of the pilot of the highest rank? [/INST]

Output: SELECT Join_Year FROM pilot ORDER BY Rank ASC LIMIT 1;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: What are the different nationalities of pilots? Show each nationality and the number of pilots of each nationality. [/INST]

Output: SELECT Nationality ,  COUNT(*) FROM pilot GROUP BY Nationality;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: Show the most common nationality of pilots. [/INST]

Output: SELECT Nationality FROM pilot GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: Show the pilot positions that have both pilots joining after year 2005 and pilots joining before 2000. [/INST]

Output: SELECT POSITION FROM pilot WHERE Join_Year	 <  2000 INTERSECT SELECT POSITION FROM pilot WHERE Join_Year	 >  2005;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: Show the names of pilots and models of aircrafts they have flied with. [/INST]

Output: SELECT T3.Pilot_name ,  T2.Model FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID  =  T3.Pilot_ID;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: Show the names of pilots and fleet series of the aircrafts they have flied with in ascending order of the rank of the pilot. [/INST]

Output: SELECT T3.Pilot_name ,  T2.Fleet_Series FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID  =  T3.Pilot_ID ORDER BY T3.Rank;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: Show the fleet series of the aircrafts flied by pilots younger than 34 [/INST]

Output: SELECT T2.Fleet_Series FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID  =  T3.Pilot_ID WHERE T3.Age  <  34;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: Show the names of pilots and the number of records they have. [/INST]

Output: SELECT T2.Pilot_name ,  COUNT(*) FROM pilot_record AS T1 JOIN pilot AS T2 ON T1.pilot_ID  =  T2.pilot_ID GROUP BY T2.Pilot_name;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: Show names of pilots that have more than one record. [/INST]

Output: SELECT T2.Pilot_name ,  COUNT(*) FROM pilot_record AS T1 JOIN pilot AS T2 ON T1.pilot_ID  =  T2.pilot_ID GROUP BY T2.Pilot_name HAVING COUNT(*)  >  1;


Input:
[INST] Here is a database schema:
aircraft :
Aircraft_ID [ INT ] primary_key
Order_Year [ INT ]
Manufacturer [ TEXT ]
Model [ TEXT ]
Fleet_Series [ TEXT ]
Powertrain [ TEXT ]
Fuel_Propulsion [ TEXT ]

pilot :
Pilot_ID [ INT ] primary_key
Pilot_name [ TEXT ]
Rank [ INT ]
Age [ INT ]
Nationality [ TEXT ]
Position [ TEXT ]
Join_Year [ INT ]
Team [ TEXT ]

pilot_record :
Record_ID [ INT ]
Pilot_ID [ INT ] primary_key pilot_record.Pilot_ID = pilot.Pilot_ID
Aircraft_ID [ INT ] pilot_record.Aircraft_ID = aircraft.Aircraft_ID
Date [ TEXT ]

Please write me a SQL statement that answers the following question: List the names of pilots that do not have any record. [/INST]

Output: SELECT Pilot_name FROM pilot WHERE Pilot_ID NOT IN (SELECT Pilot_ID FROM pilot_record);


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What document status codes do we have? [/INST]

Output: SELECT document_status_code FROM Ref_Document_Status;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the description of document status code 'working'? [/INST]

Output: SELECT document_status_description FROM Ref_Document_Status WHERE document_status_code = "working";


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What document type codes do we have? [/INST]

Output: SELECT document_type_code FROM Ref_Document_Types;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

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

Output: SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Paper";


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What are the shipping agent names? [/INST]

Output: SELECT shipping_agent_name FROM Ref_Shipping_Agents;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the shipping agent code of shipping agent UPS? [/INST]

Output: SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS";


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What are all role codes? [/INST]

Output: SELECT role_code FROM ROLES;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the description of role code ED? [/INST]

Output: SELECT role_description FROM ROLES WHERE role_code = "ED";


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: How many employees do we have? [/INST]

Output: SELECT count(*) FROM Employees;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the role of the employee named Koby? [/INST]

Output: SELECT T1.role_description FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = "Koby";


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: List all document ids and receipt dates of documents. [/INST]

Output: SELECT document_id ,  receipt_date FROM Documents;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: How many employees does each role have? List role description, id and number of employees. [/INST]

Output: SELECT T1.role_description ,  T2.role_code ,  count(*) FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code GROUP BY T2.role_code;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: List roles that have more than one employee. List the role description and number of employees. [/INST]

Output: SELECT Roles.role_description , count(Employees.employee_id) FROM ROLES JOIN Employees ON Employees.role_code = Roles.role_code GROUP BY Employees.role_code HAVING count(Employees.employee_id)  >  1;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the document status description of the document with id 1? [/INST]

Output: SELECT Ref_Document_Status.document_status_description FROM Ref_Document_Status JOIN Documents ON Documents.document_status_code = Ref_Document_Status.document_status_code WHERE Documents.document_id = 1;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: How many documents have the status code done? [/INST]

Output: SELECT count(*) FROM Documents WHERE document_status_code = "done";


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: List the document type code for the document with the id 2. [/INST]

Output: SELECT document_type_code FROM Documents WHERE document_id = 2;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: List the document ids for any documents with the status code done and the type code paper. [/INST]

Output: SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper";


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name of the shipping agent of the document with id 2? [/INST]

Output: SELECT Ref_Shipping_Agents.shipping_agent_name FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Documents.document_id = 2;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: How many documents were shipped by USPS? [/INST]

Output: SELECT count(*) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: Which shipping agent shipped the most documents? List the shipping agent name and the number of documents. [/INST]

Output: SELECT Ref_Shipping_Agents.shipping_agent_name , count(Documents.document_id) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code GROUP BY Ref_Shipping_Agents.shipping_agent_code ORDER BY count(Documents.document_id) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the receipt date of the document with id 3? [/INST]

Output: SELECT receipt_date FROM Documents WHERE document_id = 3;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What address was the document with id 4 mailed to? [/INST]

Output: SELECT Addresses.address_details FROM Addresses JOIN Documents_Mailed ON Documents_Mailed.mailed_to_address_id = Addresses.address_id WHERE document_id = 4;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the mail date of the document with id 7? [/INST]

Output: SELECT mailing_date FROM Documents_Mailed WHERE document_id = 7;


Input:
[INST] Here is a database schema:
Ref_Document_Types :
document_type_code [ TEXT ] primary_key
document_type_description [ TEXT ]

Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Ref_Document_Status :
document_status_code [ TEXT ] primary_key
document_status_description [ TEXT ]

Ref_Shipping_Agents :
shipping_agent_code [ TEXT ] primary_key
shipping_agent_name [ TEXT ]
shipping_agent_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_status_code [ TEXT ] Documents.document_status_code = Ref_Document_Status.document_status_code
document_type_code [ TEXT ] Documents.document_type_code = Ref_Document_Types.document_type_code
shipping_agent_code [ TEXT ] Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code
receipt_date [ TEXT ]
receipt_number [ TEXT ]
other_details [ TEXT ]

Employees :
employee_id [ INT ] primary_key
role_code [ TEXT ] Employees.role_code = Roles.role_code
employee_name [ TEXT ]
other_details [ TEXT ]

Document_Drafts :
document_id [ INT ] primary_key Document_Drafts.document_id = Documents.document_id
draft_number [ INT ]
draft_details [ TEXT ]

Draft_Copies :
document_id [ INT ] primary_key Draft_Copies.document_id = Document_Drafts.document_id
draft_number [ INT ] Draft_Copies.draft_number = Document_Drafts.draft_number
copy_number [ INT ]

Circulation_History :
document_id [ INT ] primary_key Circulation_History.document_id = Draft_Copies.document_id
draft_number [ INT ] Circulation_History.draft_number = Draft_Copies.draft_number
copy_number [ INT ] Circulation_History.copy_number = Draft_Copies.copy_number
employee_id [ INT ] Circulation_History.employee_id = Employees.employee_id

Documents_Mailed :
document_id [ INT ] primary_key Documents_Mailed.document_id = Documents.document_id
mailed_to_address_id [ INT ] Documents_Mailed.mailed_to_address_id = Addresses.address_id
mailing_date [ TEXT ]

Please write me a SQL statement that answers the following question: List the document ids of documents with the status done and type Paper, which not shipped by the shipping agent named USPS. [/INST]

Output: SELECT document_id FROM Documents WHERE document_status_code  =  "done" AND document_type_code = "Paper" EXCEPT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";