Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Find the emails of parties with the most popular party form. [/INST]

Output: SELECT t1.party_email FROM parties AS t1 JOIN party_forms AS t2 ON t1.party_id  =  t2.party_id WHERE t2.form_id  =  (SELECT form_id FROM party_forms GROUP BY form_id ORDER BY count(*) DESC LIMIT 1);


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: What are the party emails associated with parties that used the party form that is the most common? [/INST]

Output: SELECT t1.party_email FROM parties AS t1 JOIN party_forms AS t2 ON t1.party_id  =  t2.party_id WHERE t2.form_id  =  (SELECT form_id FROM party_forms GROUP BY form_id ORDER BY count(*) DESC LIMIT 1);


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: List all the name of organizations in order of the date formed. [/INST]

Output: SELECT organization_name FROM organizations ORDER BY date_formed ASC;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of organizations, ordered by the date they were formed, ascending? [/INST]

Output: SELECT organization_name FROM organizations ORDER BY date_formed ASC;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name of the youngest organization. [/INST]

Output: SELECT organization_name FROM organizations ORDER BY date_formed DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name of the organization that was formed most recently? [/INST]

Output: SELECT organization_name FROM organizations ORDER BY date_formed DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Find the last name of the latest contact individual of the organization "Labour Party". [/INST]

Output: SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id  =  t2.organization_id JOIN individuals AS t3 ON t2.individual_id  =  t3.individual_id WHERE t1.organization_name  =  "Labour Party" ORDER BY t2.date_contact_to DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the last name of the contact individual from the Labour party organization who was contacted most recently? [/INST]

Output: SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id  =  t2.organization_id JOIN individuals AS t3 ON t2.individual_id  =  t3.individual_id WHERE t1.organization_name  =  "Labour Party" ORDER BY t2.date_contact_to DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Find the last name of the first ever contact person of the organization with the highest UK Vat number. [/INST]

Output: SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id  =  t2.organization_id JOIN individuals AS t3 ON t2.individual_id  =  t3.individual_id WHERE t1.uk_vat_number  =  (SELECT max(uk_vat_number) FROM organizations) ORDER BY t2.date_contact_to ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the last name of the first individual contacted from the organization with the maximum UK Vat number across all organizations? [/INST]

Output: SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id  =  t2.organization_id JOIN individuals AS t3 ON t2.individual_id  =  t3.individual_id WHERE t1.uk_vat_number  =  (SELECT max(uk_vat_number) FROM organizations) ORDER BY t2.date_contact_to ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

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

Output: SELECT count(*) FROM services;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

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

Output: SELECT count(*) FROM services;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Find name of the services that has never been used. [/INST]

Output: SELECT service_name FROM services EXCEPT SELECT t1.service_name FROM services AS t1 JOIN party_services AS t2 ON t1.service_id  =  t2.service_id;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of the services that have never been used? [/INST]

Output: SELECT service_name FROM services EXCEPT SELECT t1.service_name FROM services AS t1 JOIN party_services AS t2 ON t1.service_id  =  t2.service_id;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name of all the cities and states. [/INST]

Output: SELECT town_city FROM addresses UNION SELECT state_province_county FROM addresses;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of all cities and states? [/INST]

Output: SELECT town_city FROM addresses UNION SELECT state_province_county FROM addresses;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: How many cities are there in state "Colorado"? [/INST]

Output: SELECT count(*) FROM addresses WHERE state_province_county  =  "Colorado";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Count the number of cities in the state of Colorado. [/INST]

Output: SELECT count(*) FROM addresses WHERE state_province_county  =  "Colorado";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Find the payment method code used by more than 3 parties. [/INST]

Output: SELECT payment_method_code FROM parties GROUP BY payment_method_code HAVING count(*)  >  3;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: What are the payment method codes that have been used by more than 3 parties? [/INST]

Output: SELECT payment_method_code FROM parties GROUP BY payment_method_code HAVING count(*)  >  3;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name of organizations whose names contain "Party". [/INST]

Output: SELECT organization_name FROM organizations WHERE organization_name LIKE "%Party%";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of organizations that contain the word "Party"? [/INST]

Output: SELECT organization_name FROM organizations WHERE organization_name LIKE "%Party%";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: How many distinct payment methods are used by parties? [/INST]

Output: SELECT count(DISTINCT payment_method_code) FROM parties;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Count the number of different payment method codes used by parties. [/INST]

Output: SELECT count(DISTINCT payment_method_code) FROM parties;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Which is the email of the party that has used the services the most number of times? [/INST]

Output: SELECT t1.party_email FROM parties AS t1 JOIN party_services AS t2 ON t1.party_id  =  t2.customer_id GROUP BY t1.party_email ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Return the party email that has used party services the greatest number of times. [/INST]

Output: SELECT t1.party_email FROM parties AS t1 JOIN party_services AS t2 ON t1.party_id  =  t2.customer_id GROUP BY t1.party_email ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Which state can address "6862 Kaitlyn Knolls" possibly be in? [/INST]

Output: SELECT state_province_county FROM addresses WHERE line_1_number_building LIKE "%6862 Kaitlyn Knolls%";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Give the state corresponding to the line number building "6862 Kaitlyn Knolls". [/INST]

Output: SELECT state_province_county FROM addresses WHERE line_1_number_building LIKE "%6862 Kaitlyn Knolls%";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name of organization that has the greatest number of contact individuals? [/INST]

Output: SELECT t1.organization_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id  =  t2.organization_id GROUP BY t1.organization_name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Return the name of the organization which has the most contact individuals. [/INST]

Output: SELECT t1.organization_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id  =  t2.organization_id GROUP BY t1.organization_name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: Find the last name of the individuals that have been contact individuals of an organization. [/INST]

Output: SELECT DISTINCT t1.individual_last_name FROM individuals AS t1 JOIN organization_contact_individuals AS t2 ON t1.individual_id  =  t2.individual_id;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
town_city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Services :
service_id [ INT ] primary_key
service_type_code [ TEXT ]
service_name [ TEXT ]
service_descriptio [ TEXT ]

Forms :
form_id [ INT ] primary_key
form_type_code [ TEXT ]
service_id [ INT ] Forms.service_id = Services.service_id
form_number [ TEXT ]
form_name [ TEXT ]
form_description [ TEXT ]

Individuals :
individual_id [ INT ] primary_key
individual_first_name [ TEXT ]
individual_middle_name [ TEXT ]
inidividual_phone [ TEXT ]
individual_email [ TEXT ]
individual_address [ TEXT ]
individual_last_name [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
date_formed [ TEXT ]
organization_name [ TEXT ]
uk_vat_number [ TEXT ]

Parties :
party_id [ INT ] primary_key
payment_method_code [ TEXT ]
party_phone [ TEXT ]
party_email [ TEXT ]

Organization_Contact_Individuals :
individual_id [ INT ] primary_key Organization_Contact_Individuals.individual_id = Individuals.individual_id
organization_id [ INT ] Organization_Contact_Individuals.organization_id = Organizations.organization_id
date_contact_from [ TEXT ]
date_contact_to [ TEXT ]

Party_Addresses :
party_id [ INT ] primary_key Party_Addresses.party_id = Parties.party_id
address_id [ INT ] Party_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
address_type_code [ TEXT ]
date_address_to [ TEXT ]

Party_Forms :
party_id [ INT ] primary_key Party_Forms.party_id = Parties.party_id
form_id [ INT ] Party_Forms.form_id = Forms.form_id
date_completion_started [ TEXT ]
form_status_code [ TEXT ]
date_fully_completed [ TEXT ]

Party_Services :
booking_id [ INT ]
customer_id [ INT ] Party_Services.customer_id = Parties.party_id
service_id [ INT ] Party_Services.service_id = Services.service_id
service_datetime [ TEXT ]
booking_made_date [ TEXT ]

Please write me a SQL statement that answers the following question: What are the last names of individuals who have been contact individuals for an organization? [/INST]

Output: SELECT DISTINCT t1.individual_last_name FROM individuals AS t1 JOIN organization_contact_individuals AS t2 ON t1.individual_id  =  t2.individual_id;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

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

Output: SELECT count(*) FROM driver;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: Show the name, home city, and age for all drivers. [/INST]

Output: SELECT name ,  home_city ,  age FROM driver;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

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

Output: SELECT party ,  count(*) FROM driver GROUP BY party;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: Show the name of drivers in descending order of age. [/INST]

Output: SELECT name FROM driver ORDER BY age DESC;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: Show all different home cities. [/INST]

Output: SELECT DISTINCT home_city FROM driver;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: Show the home city with the most number of drivers. [/INST]

Output: SELECT home_city FROM driver GROUP BY home_city ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: Show the party with drivers from Hartford and drivers older than 40. [/INST]

Output: SELECT party FROM driver WHERE home_city  =  'Hartford' AND age  >  40;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: Show home city where at least two drivers older than 40 are from. [/INST]

Output: SELECT home_city FROM driver WHERE age  >  40 GROUP BY home_city HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: Show all home cities except for those having a driver older than 40. [/INST]

Output: SELECT home_city FROM driver EXCEPT SELECT home_city FROM driver WHERE age  >  40;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: Show the names of the drivers without a school bus. [/INST]

Output: SELECT name FROM driver WHERE driver_id NOT IN (SELECT driver_id FROM school_bus);


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: Show the types of schools that have two schools. [/INST]

Output: SELECT TYPE FROM school GROUP BY TYPE HAVING count(*)  =  2;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: Show the school name and driver name for all school buses. [/INST]

Output: SELECT T2.school ,  T3.name FROM school_bus AS T1 JOIN school AS T2 ON T1.school_id  =  T2.school_id JOIN driver AS T3 ON T1.driver_id  =  T3.driver_id;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: What is the maximum, minimum and average years spent working on a school bus? [/INST]

Output: SELECT max(years_working) ,  min(years_working) ,  avg(years_working) FROM school_bus;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: Show the school name and type for schools without a school bus. [/INST]

Output: SELECT school ,  TYPE FROM school WHERE school_id NOT IN (SELECT school_id FROM school_bus);


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: Show the type of school and the number of buses for each type. [/INST]

Output: SELECT T2.type ,  count(*) FROM school_bus AS T1 JOIN school AS T2 ON T1.school_id  =  T2.school_id GROUP BY T2.type;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: How many drivers are from Hartford city or younger than 40? [/INST]

Output: SELECT count(*) FROM driver WHERE home_city  =  'Hartford' OR age  <  40;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: List names for drivers from Hartford city and younger than 40. [/INST]

Output: SELECT name FROM driver WHERE home_city  =  'Hartford' AND age  <  40;


Input:
[INST] Here is a database schema:
driver :
Driver_ID [ INT ] primary_key
Name [ TEXT ]
Party [ TEXT ]
Home_city [ TEXT ]
Age [ INT ]

school :
School_ID [ INT ] primary_key
Grade [ TEXT ]
School [ TEXT ]
Location [ TEXT ]
Type [ TEXT ]

school_bus :
School_ID [ INT ] primary_key school_bus.School_ID = school.School_ID
Driver_ID [ INT ] school_bus.Driver_ID = driver.Driver_ID
Years_Working [ INT ]
If_full_time [ TEXT ]

Please write me a SQL statement that answers the following question: find the name of driver who is driving the school bus with the longest working history. [/INST]

Output: SELECT t1.name FROM driver AS t1 JOIN school_bus AS t2 ON t1.driver_id  =  t2.driver_id ORDER BY years_working DESC LIMIT 1;


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: How many flights have a velocity larger than 200? [/INST]

Output: SELECT count(*) FROM flight WHERE velocity  >  200;


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: List the vehicle flight number, date and pilot of all the flights, ordered by altitude. [/INST]

Output: SELECT vehicle_flight_number ,  date ,  pilot FROM flight ORDER BY altitude ASC;


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: List the id, country, city and name of the airports ordered alphabetically by the name. [/INST]

Output: SELECT id ,  country ,  city ,  name FROM airport ORDER BY name;


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: What is maximum group equity shareholding of the companies? [/INST]

Output: SELECT max(group_equity_shareholding) FROM operate_company;


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: What is the velocity of the pilot named 'Thompson'? [/INST]

Output: SELECT avg(velocity) FROM flight WHERE pilot  =  'Thompson';


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: What are the names and types of the companies that have ever operated a flight? [/INST]

Output: SELECT T1.name ,  T1.type FROM operate_company AS T1 JOIN flight AS t2 ON T1.id  =  T2.company_id;


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: What are the names of the airports which are not in the country 'Iceland'? [/INST]

Output: SELECT name FROM airport WHERE country != 'Iceland';


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: What are the distinct types of the companies that have operated any flights with velocity less than 200? [/INST]

Output: SELECT DISTINCT T1.type FROM operate_company AS T1 JOIN flight AS t2 ON T1.id  =  T2.company_id WHERE T2.velocity  <  200;


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: What are the ids and names of the companies that operated more than one flight? [/INST]

Output: SELECT T1.id ,  T1.name FROM operate_company AS T1 JOIN flight AS t2 ON T1.id  =  T2.company_id GROUP BY T1.id HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: What is the id, name and IATA code of the airport that had most number of flights? [/INST]

Output: SELECT T1.id ,  T1.name ,  T1.IATA FROM airport AS T1 JOIN flight AS T2 ON T1.id  =  T2.airport_id GROUP BY T2.id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: What are the different pilot names who had piloted a flight in the country 'United States' or in the airport named 'Billund Airport'? [/INST]

Output: SELECT DISTINCT T2.pilot FROM airport AS T1 JOIN flight AS T2 ON T1.id  =  T2.airport_id WHERE T1.country  =  'United States' OR T1.name  =  'Billund Airport';


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: What is the most common company type, and how many are there? [/INST]

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


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: How many airports haven't the pilot 'Thompson' driven an aircraft? [/INST]

Output: SELECT count(*) FROM airport WHERE id NOT IN ( SELECT airport_id FROM flight WHERE pilot  =  'Thompson' );


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: List the name of the pilots who have flied for both a company that mainly provide 'Cargo' services and a company that runs 'Catering services' activities. [/INST]

Output: SELECT T2.pilot FROM operate_company AS T1 JOIN flight AS t2 ON T1.id  =  T2.company_id WHERE T1.principal_activities  =  'Cargo' INTERSECT SELECT T2.pilot FROM operate_company AS T1 JOIN flight AS t2 ON T1.id  =  T2.company_id WHERE T1.principal_activities  =  'Catering services';


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: Which of the airport names contains the word 'international'? [/INST]

Output: SELECT name FROM airport WHERE name LIKE '%international%';


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: How many companies operates airlines in each airport? [/INST]

Output: SELECT T3.id ,  count(*) FROM operate_company AS T1 JOIN flight AS t2 ON T1.id  =  T2.company_id JOIN airport AS T3 ON T2.airport_id  =  T3.id GROUP BY T3.id;


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: how many airports are there in each country? [/INST]

Output: SELECT count(*) ,  country FROM airport GROUP BY country;


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: which countries have more than 2 airports? [/INST]

Output: SELECT country FROM airport GROUP BY country HAVING count(*)  >  2;


Input:
[INST] Here is a database schema:
airport :
id [ INT ] primary_key
City [ TEXT ]
Country [ TEXT ]
IATA [ TEXT ]
ICAO [ TEXT ]
name [ TEXT ]

operate_company :
id [ INT ] primary_key
name [ TEXT ]
Type [ TEXT ]
Principal_activities [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]

flight :
id [ INT ] primary_key
Vehicle_Flight_number [ TEXT ]
Date [ TEXT ]
Pilot [ TEXT ]
Velocity [ INT ]
Altitude [ INT ]
airport_id [ INT ] flight.airport_id = airport.id
company_id [ INT ] flight.company_id = operate_company.id

Please write me a SQL statement that answers the following question: which pilot is in charge of the most number of flights? [/INST]

Output: SELECT pilot FROM flight GROUP BY pilot ORDER BY count(*) DESC LIMIT 1;