Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Return the ids of all products that were ordered more than three times or supplied more than 80000. [/INST]

Output: SELECT product_id FROM Order_Items GROUP BY product_id HAVING count(*)  >  3 UNION SELECT product_id FROM Product_Suppliers GROUP BY product_id HAVING sum(total_amount_purchased)  >  80000;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the ids of all products that were either ordered more than 3 times or have a cumulative amount purchased of above 80000? [/INST]

Output: SELECT product_id FROM Order_Items GROUP BY product_id HAVING count(*)  >  3 UNION SELECT product_id FROM Product_Suppliers GROUP BY product_id HAVING sum(total_amount_purchased)  >  80000;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are id and name of the products whose price is lower than 600 or higher than 900? [/INST]

Output: SELECT product_id ,  product_name FROM products WHERE product_price  <  600 OR product_price  >  900;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Give the ids and names of products with price lower than 600 or higher than 900. [/INST]

Output: SELECT product_id ,  product_name FROM products WHERE product_price  <  600 OR product_price  >  900;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Find the id of suppliers whose average amount purchased for each product is above 50000 or below 30000. [/INST]

Output: SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id HAVING avg(total_amount_purchased)  >  50000 OR avg(total_amount_purchased)  <  30000;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the ids of suppliers which have an average amount purchased of above 50000 or below 30000? [/INST]

Output: SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id HAVING avg(total_amount_purchased)  >  50000 OR avg(total_amount_purchased)  <  30000;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the average amount purchased and value purchased for the supplier who supplies the most products. [/INST]

Output: SELECT avg(total_amount_purchased) ,  avg(total_value_purchased) FROM Product_Suppliers WHERE supplier_id  =  (SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id ORDER BY count(*) DESC LIMIT 1);


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Return the average total amount purchased and total value purchased for the supplier who supplies the greatest number of products. [/INST]

Output: SELECT avg(total_amount_purchased) ,  avg(total_value_purchased) FROM Product_Suppliers WHERE supplier_id  =  (SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id ORDER BY count(*) DESC LIMIT 1);


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What is the largest and smallest customer codes? [/INST]

Output: SELECT max(customer_code) ,  min(customer_code) FROM Customers;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Return the maximum and minimum customer codes. [/INST]

Output: SELECT max(customer_code) ,  min(customer_code) FROM Customers;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: List the names of all the distinct customers who bought a keyboard. [/INST]

Output: SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id JOIN order_items AS T3 ON T2.order_id  =  T3.order_id JOIN products AS T4 ON T3.product_id  =  T4.product_id WHERE T4.product_name  =  "keyboard";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the distinct names of customers who have purchased a keyboard? [/INST]

Output: SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id JOIN order_items AS T3 ON T2.order_id  =  T3.order_id JOIN products AS T4 ON T3.product_id  =  T4.product_id WHERE T4.product_name  =  "keyboard";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: List the names and phone numbers of all the distinct suppliers who supply red jeans. [/INST]

Output: SELECT DISTINCT T1.supplier_name ,  T1.supplier_phone FROM suppliers AS T1 JOIN product_suppliers AS T2 ON T1.supplier_id  =  T2.supplier_id JOIN products AS T3 ON T2.product_id  =  T3.product_id WHERE T3.product_name  =  "red jeans";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the distinct names and phone numbers for suppliers who have red jeans? [/INST]

Output: SELECT DISTINCT T1.supplier_name ,  T1.supplier_phone FROM suppliers AS T1 JOIN product_suppliers AS T2 ON T1.supplier_id  =  T2.supplier_id JOIN products AS T3 ON T2.product_id  =  T3.product_id WHERE T3.product_name  =  "red jeans";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the highest and lowest prices of products, grouped by and alphabetically ordered by product type? [/INST]

Output: SELECT max(product_price) ,  min(product_price) ,  product_type_code FROM products GROUP BY product_type_code ORDER BY product_type_code;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Give the maximum and minimum product prices for each product type, grouped and ordered by product type. [/INST]

Output: SELECT max(product_price) ,  min(product_price) ,  product_type_code FROM products GROUP BY product_type_code ORDER BY product_type_code;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: List the order id, customer id for orders in Cancelled status, ordered by their order dates. [/INST]

Output: SELECT order_id ,  customer_id FROM customer_orders WHERE order_status_code  =   "Cancelled" ORDER BY order_date;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the order ids and customer ids for orders that have been Cancelled, sorted by their order dates? [/INST]

Output: SELECT order_id ,  customer_id FROM customer_orders WHERE order_status_code  =   "Cancelled" ORDER BY order_date;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Find the names of products that were bought by at least two distinct customers. [/INST]

Output: SELECT DISTINCT T3.product_name FROM customer_orders AS T1 JOIN order_items AS T2 ON T1.order_id  =  T2.order_id JOIN products AS T3 ON T2.product_id  =  T3.product_id GROUP BY T3.product_id HAVING COUNT (DISTINCT T1.customer_id)  >=  2;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the distinct names of products purchased by at least two different customers? [/INST]

Output: SELECT DISTINCT T3.product_name FROM customer_orders AS T1 JOIN order_items AS T2 ON T1.order_id  =  T2.order_id JOIN products AS T3 ON T2.product_id  =  T3.product_id GROUP BY T3.product_id HAVING COUNT (DISTINCT T1.customer_id)  >=  2;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Find the names of customers who have bought by at least three distinct products. [/INST]

Output: SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id JOIN order_items AS T3 ON T2.order_id  =  T3.order_id GROUP BY T1.customer_id HAVING COUNT (DISTINCT T3.product_id)  >=  3;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the distinct names of customers who have purchased at least three different products? [/INST]

Output: SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id JOIN order_items AS T3 ON T2.order_id  =  T3.order_id GROUP BY T1.customer_id HAVING COUNT (DISTINCT T3.product_id)  >=  3;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name and gender of the staff who has been assigned the job of Sales Person but never Clerical Staff. [/INST]

Output: SELECT T1.staff_name ,  T1.staff_gender FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id  =  T2.staff_id WHERE T2.job_title_code  =  "Sales Person" EXCEPT SELECT T1.staff_name ,  T1.staff_gender FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id  =  T2.staff_id WHERE T2.job_title_code  =  "Clerical Staff";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names and genders of staff who have held the title Sales Person, but never Clerical Staff? [/INST]

Output: SELECT T1.staff_name ,  T1.staff_gender FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id  =  T2.staff_id WHERE T2.job_title_code  =  "Sales Person" EXCEPT SELECT T1.staff_name ,  T1.staff_gender FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id  =  T2.staff_id WHERE T2.job_title_code  =  "Clerical Staff";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Find the id and name of customers whose address contains WY state and do not use credit card for payment. [/INST]

Output: SELECT customer_id ,  customer_name FROM customers WHERE customer_address LIKE "%WY%" AND payment_method_code != "Credit Card";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the ids and names of customers with addressed that contain WY and who do not use a credit card for payment? [/INST]

Output: SELECT customer_id ,  customer_name FROM customers WHERE customer_address LIKE "%WY%" AND payment_method_code != "Credit Card";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Find the average price of all product clothes. [/INST]

Output: SELECT avg(product_price) FROM products WHERE product_type_code  =  'Clothes';


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What is the average price of clothes? [/INST]

Output: SELECT avg(product_price) FROM products WHERE product_type_code  =  'Clothes';


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name of the most expensive hardware product. [/INST]

Output: SELECT product_name FROM products WHERE product_type_code  =  'Hardware' ORDER BY product_price DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name of the hardware product with the greatest price? [/INST]

Output: SELECT product_name FROM products WHERE product_type_code  =  'Hardware' ORDER BY product_price DESC LIMIT 1;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

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

Output: SELECT count(*) FROM aircraft;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What is the number of aircraft? [/INST]

Output: SELECT count(*) FROM aircraft;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

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

Output: SELECT Description FROM aircraft;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the descriptions for the aircrafts? [/INST]

Output: SELECT Description FROM aircraft;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What is the average number of international passengers of all airports? [/INST]

Output: SELECT avg(International_Passengers) FROM airport;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What is the average number of international passengers for an airport? [/INST]

Output: SELECT avg(International_Passengers) FROM airport;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the number of international and domestic passengers of the airport named London "Heathrow"? [/INST]

Output: SELECT International_Passengers ,  Domestic_Passengers FROM airport WHERE Airport_Name  =  "London Heathrow";


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: How many international and domestic passengers are there in the airport London Heathrow? [/INST]

Output: SELECT International_Passengers ,  Domestic_Passengers FROM airport WHERE Airport_Name  =  "London Heathrow";


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the total number of Domestic Passengers of airports that contain the word "London". [/INST]

Output: SELECT sum(Domestic_Passengers) FROM airport WHERE Airport_Name LIKE "%London%";


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the total number of domestic passengers at all London airports? [/INST]

Output: SELECT sum(Domestic_Passengers) FROM airport WHERE Airport_Name LIKE "%London%";


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the maximum and minimum number of transit passengers of all aiports. [/INST]

Output: SELECT max(Transit_Passengers) ,  min(Transit_Passengers) FROM airport;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What is the maximum and mininum number of transit passengers for all airports? [/INST]

Output: SELECT max(Transit_Passengers) ,  min(Transit_Passengers) FROM airport;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the name of pilots aged 25 or older? [/INST]

Output: SELECT Name FROM pilot WHERE Age  >=  25;