richardr1126/spider-context-instruct huggingface dataset:
### Instruction:

Convert text to sql: Return the id of the department with the fewest staff assignments. | addresses : address_id , address_details | staff : staff_id , staff_gender , staff_name | suppliers : supplier_id , supplier_name , supplier_phone | department_store_chain : dept_store_chain_id , dept_store_chain_name | customers : customer_id , payment_method_code , customer_code , customer_name , customer_address , customer_phone , customer_email | products : product_id , product_type_code , product_name , product_price | supplier_addresses : supplier_id , address_id , date_from , date_to | customer_addresses : customer_id , address_id , date_from , date_to | customer_orders : order_id , customer_id , order_status_code , order_date | department_stores : dept_store_id , dept_store_chain_id , store_name , store_address , store_phone , store_email | departments : department_id , dept_store_id , department_name | order_items : order_item_id , order_id , product_id | product_suppliers : product_id , supplier_id , date_supplied_from , date_supplied_to , total_amount_purchased , total_value_purchased | staff_department_assignments : staff_id , department_id , date_assigned_from , job_title_code , date_assigned_to | supplier_addresses.supplier_id = suppliers.supplier_id | supplier_addresses.address_id = addresses.address_id | customer_addresses.customer_id = customers.customer_id | customer_addresses.address_id = addresses.address_id | customer_orders.customer_id = customers.customer_id | department_stores.dept_store_chain_id = department_store_chain.dept_store_chain_id | departments.dept_store_id = department_stores.dept_store_id | order_items.product_id = products.product_id | order_items.order_id = customer_orders.order_id | product_suppliers.product_id = products.product_id | product_suppliers.supplier_id = suppliers.supplier_id | staff_department_assignments.staff_id = staff.staff_id | staff_department_assignments.department_id = departments.department_id | 

### Response:

select department_id from staff_department_assignments group by department_id order by count ( * ) asc limit 1
### Instruction:

Convert text to sql: For each product type, return the maximum and minimum price. | addresses : address_id , address_details | staff : staff_id , staff_gender , staff_name | suppliers : supplier_id , supplier_name , supplier_phone | department_store_chain : dept_store_chain_id , dept_store_chain_name | customers : customer_id , payment_method_code , customer_code , customer_name , customer_address , customer_phone , customer_email | products : product_id , product_type_code , product_name , product_price | supplier_addresses : supplier_id , address_id , date_from , date_to | customer_addresses : customer_id , address_id , date_from , date_to | customer_orders : order_id , customer_id , order_status_code , order_date | department_stores : dept_store_id , dept_store_chain_id , store_name , store_address , store_phone , store_email | departments : department_id , dept_store_id , department_name | order_items : order_item_id , order_id , product_id | product_suppliers : product_id , supplier_id , date_supplied_from , date_supplied_to , total_amount_purchased , total_value_purchased | staff_department_assignments : staff_id , department_id , date_assigned_from , job_title_code , date_assigned_to | supplier_addresses.supplier_id = suppliers.supplier_id | supplier_addresses.address_id = addresses.address_id | customer_addresses.customer_id = customers.customer_id | customer_addresses.address_id = addresses.address_id | customer_orders.customer_id = customers.customer_id | department_stores.dept_store_chain_id = department_store_chain.dept_store_chain_id | departments.dept_store_id = department_stores.dept_store_id | order_items.product_id = products.product_id | order_items.order_id = customer_orders.order_id | product_suppliers.product_id = products.product_id | product_suppliers.supplier_id = suppliers.supplier_id | staff_department_assignments.staff_id = staff.staff_id | staff_department_assignments.department_id = departments.department_id | 

### Response:

select product_type_code , max ( product_price ) , min ( product_price ) from products group by product_type_code
### Instruction:

Convert text to sql: What are the maximum and minimum product prices for each product type? | addresses : address_id , address_details | staff : staff_id , staff_gender , staff_name | suppliers : supplier_id , supplier_name , supplier_phone | department_store_chain : dept_store_chain_id , dept_store_chain_name | customers : customer_id , payment_method_code , customer_code , customer_name , customer_address , customer_phone , customer_email | products : product_id , product_type_code , product_name , product_price | supplier_addresses : supplier_id , address_id , date_from , date_to | customer_addresses : customer_id , address_id , date_from , date_to | customer_orders : order_id , customer_id , order_status_code , order_date | department_stores : dept_store_id , dept_store_chain_id , store_name , store_address , store_phone , store_email | departments : department_id , dept_store_id , department_name | order_items : order_item_id , order_id , product_id | product_suppliers : product_id , supplier_id , date_supplied_from , date_supplied_to , total_amount_purchased , total_value_purchased | staff_department_assignments : staff_id , department_id , date_assigned_from , job_title_code , date_assigned_to | supplier_addresses.supplier_id = suppliers.supplier_id | supplier_addresses.address_id = addresses.address_id | customer_addresses.customer_id = customers.customer_id | customer_addresses.address_id = addresses.address_id | customer_orders.customer_id = customers.customer_id | department_stores.dept_store_chain_id = department_store_chain.dept_store_chain_id | departments.dept_store_id = department_stores.dept_store_id | order_items.product_id = products.product_id | order_items.order_id = customer_orders.order_id | product_suppliers.product_id = products.product_id | product_suppliers.supplier_id = suppliers.supplier_id | staff_department_assignments.staff_id = staff.staff_id | staff_department_assignments.department_id = departments.department_id | 

### Response:

select product_type_code , max ( product_price ) , min ( product_price ) from products group by product_type_code
### Instruction:

Convert text to sql: Find the product type whose average price is higher than the average price of all products. | addresses : address_id , address_details | staff : staff_id , staff_gender , staff_name | suppliers : supplier_id , supplier_name , supplier_phone | department_store_chain : dept_store_chain_id , dept_store_chain_name | customers : customer_id , payment_method_code , customer_code , customer_name , customer_address , customer_phone , customer_email | products : product_id , product_type_code , product_name , product_price | supplier_addresses : supplier_id , address_id , date_from , date_to | customer_addresses : customer_id , address_id , date_from , date_to | customer_orders : order_id , customer_id , order_status_code , order_date | department_stores : dept_store_id , dept_store_chain_id , store_name , store_address , store_phone , store_email | departments : department_id , dept_store_id , department_name | order_items : order_item_id , order_id , product_id | product_suppliers : product_id , supplier_id , date_supplied_from , date_supplied_to , total_amount_purchased , total_value_purchased | staff_department_assignments : staff_id , department_id , date_assigned_from , job_title_code , date_assigned_to | supplier_addresses.supplier_id = suppliers.supplier_id | supplier_addresses.address_id = addresses.address_id | customer_addresses.customer_id = customers.customer_id | customer_addresses.address_id = addresses.address_id | customer_orders.customer_id = customers.customer_id | department_stores.dept_store_chain_id = department_store_chain.dept_store_chain_id | departments.dept_store_id = department_stores.dept_store_id | order_items.product_id = products.product_id | order_items.order_id = customer_orders.order_id | product_suppliers.product_id = products.product_id | product_suppliers.supplier_id = suppliers.supplier_id | staff_department_assignments.staff_id = staff.staff_id | staff_department_assignments.department_id = departments.department_id | 

### Response:

select product_type_code from products group by product_type_code having avg ( product_price ) > ( select avg ( product_price ) from products )
### Instruction:

Convert text to sql: What is the code of the product type with an average price higher than the average price of all products? | addresses : address_id , address_details | staff : staff_id , staff_gender , staff_name | suppliers : supplier_id , supplier_name , supplier_phone | department_store_chain : dept_store_chain_id , dept_store_chain_name | customers : customer_id , payment_method_code , customer_code , customer_name , customer_address , customer_phone , customer_email | products : product_id , product_type_code , product_name , product_price | supplier_addresses : supplier_id , address_id , date_from , date_to | customer_addresses : customer_id , address_id , date_from , date_to | customer_orders : order_id , customer_id , order_status_code , order_date | department_stores : dept_store_id , dept_store_chain_id , store_name , store_address , store_phone , store_email | departments : department_id , dept_store_id , department_name | order_items : order_item_id , order_id , product_id | product_suppliers : product_id , supplier_id , date_supplied_from , date_supplied_to , total_amount_purchased , total_value_purchased | staff_department_assignments : staff_id , department_id , date_assigned_from , job_title_code , date_assigned_to | supplier_addresses.supplier_id = suppliers.supplier_id | supplier_addresses.address_id = addresses.address_id | customer_addresses.customer_id = customers.customer_id | customer_addresses.address_id = addresses.address_id | customer_orders.customer_id = customers.customer_id | department_stores.dept_store_chain_id = department_store_chain.dept_store_chain_id | departments.dept_store_id = department_stores.dept_store_id | order_items.product_id = products.product_id | order_items.order_id = customer_orders.order_id | product_suppliers.product_id = products.product_id | product_suppliers.supplier_id = suppliers.supplier_id | staff_department_assignments.staff_id = staff.staff_id | staff_department_assignments.department_id = departments.department_id | 

### Response:

select product_type_code from products group by product_type_code having avg ( product_price ) > ( select avg ( product_price ) from products )
### Instruction:

Convert text to sql: Find the id and name of the staff who has been assigned for the shortest period. | addresses : address_id , address_details | staff : staff_id , staff_gender , staff_name | suppliers : supplier_id , supplier_name , supplier_phone | department_store_chain : dept_store_chain_id , dept_store_chain_name | customers : customer_id , payment_method_code , customer_code , customer_name , customer_address , customer_phone , customer_email | products : product_id , product_type_code , product_name , product_price | supplier_addresses : supplier_id , address_id , date_from , date_to | customer_addresses : customer_id , address_id , date_from , date_to | customer_orders : order_id , customer_id , order_status_code , order_date | department_stores : dept_store_id , dept_store_chain_id , store_name , store_address , store_phone , store_email | departments : department_id , dept_store_id , department_name | order_items : order_item_id , order_id , product_id | product_suppliers : product_id , supplier_id , date_supplied_from , date_supplied_to , total_amount_purchased , total_value_purchased | staff_department_assignments : staff_id , department_id , date_assigned_from , job_title_code , date_assigned_to | supplier_addresses.supplier_id = suppliers.supplier_id | supplier_addresses.address_id = addresses.address_id | customer_addresses.customer_id = customers.customer_id | customer_addresses.address_id = addresses.address_id | customer_orders.customer_id = customers.customer_id | department_stores.dept_store_chain_id = department_store_chain.dept_store_chain_id | departments.dept_store_id = department_stores.dept_store_id | order_items.product_id = products.product_id | order_items.order_id = customer_orders.order_id | product_suppliers.product_id = products.product_id | product_suppliers.supplier_id = suppliers.supplier_id | staff_department_assignments.staff_id = staff.staff_id | staff_department_assignments.department_id = departments.department_id | 

### Response:

select staff.staff_id , staff.staff_name from staff join staff_department_assignments on staff.staff_id = staff_department_assignments.staff_id order by date_assigned_to - date_assigned_from asc limit 1
### Instruction:

Convert text to sql: What is the id and name of the staff who has been assigned for the least amount of time? | addresses : address_id , address_details | staff : staff_id , staff_gender , staff_name | suppliers : supplier_id , supplier_name , supplier_phone | department_store_chain : dept_store_chain_id , dept_store_chain_name | customers : customer_id , payment_method_code , customer_code , customer_name , customer_address , customer_phone , customer_email | products : product_id , product_type_code , product_name , product_price | supplier_addresses : supplier_id , address_id , date_from , date_to | customer_addresses : customer_id , address_id , date_from , date_to | customer_orders : order_id , customer_id , order_status_code , order_date | department_stores : dept_store_id , dept_store_chain_id , store_name , store_address , store_phone , store_email | departments : department_id , dept_store_id , department_name | order_items : order_item_id , order_id , product_id | product_suppliers : product_id , supplier_id , date_supplied_from , date_supplied_to , total_amount_purchased , total_value_purchased | staff_department_assignments : staff_id , department_id , date_assigned_from , job_title_code , date_assigned_to | supplier_addresses.supplier_id = suppliers.supplier_id | supplier_addresses.address_id = addresses.address_id | customer_addresses.customer_id = customers.customer_id | customer_addresses.address_id = addresses.address_id | customer_orders.customer_id = customers.customer_id | department_stores.dept_store_chain_id = department_store_chain.dept_store_chain_id | departments.dept_store_id = department_stores.dept_store_id | order_items.product_id = products.product_id | order_items.order_id = customer_orders.order_id | product_suppliers.product_id = products.product_id | product_suppliers.supplier_id = suppliers.supplier_id | staff_department_assignments.staff_id = staff.staff_id | staff_department_assignments.department_id = departments.department_id | 

### Response:

select staff.staff_id , staff.staff_name from staff join staff_department_assignments on staff.staff_id = staff_department_assignments.staff_id order by date_assigned_to - date_assigned_from asc limit 1
### Instruction:

Convert text to sql: Return the names and ids of all products whose price is between 600 and 700. | addresses : address_id , address_details | staff : staff_id , staff_gender , staff_name | suppliers : supplier_id , supplier_name , supplier_phone | department_store_chain : dept_store_chain_id , dept_store_chain_name | customers : customer_id , payment_method_code , customer_code , customer_name , customer_address , customer_phone , customer_email | products : product_id , product_type_code , product_name , product_price | supplier_addresses : supplier_id , address_id , date_from , date_to | customer_addresses : customer_id , address_id , date_from , date_to | customer_orders : order_id , customer_id , order_status_code , order_date | department_stores : dept_store_id , dept_store_chain_id , store_name , store_address , store_phone , store_email | departments : department_id , dept_store_id , department_name | order_items : order_item_id , order_id , product_id | product_suppliers : product_id , supplier_id , date_supplied_from , date_supplied_to , total_amount_purchased , total_value_purchased | staff_department_assignments : staff_id , department_id , date_assigned_from , job_title_code , date_assigned_to | supplier_addresses.supplier_id = suppliers.supplier_id | supplier_addresses.address_id = addresses.address_id | customer_addresses.customer_id = customers.customer_id | customer_addresses.address_id = addresses.address_id | customer_orders.customer_id = customers.customer_id | department_stores.dept_store_chain_id = department_store_chain.dept_store_chain_id | departments.dept_store_id = department_stores.dept_store_id | order_items.product_id = products.product_id | order_items.order_id = customer_orders.order_id | product_suppliers.product_id = products.product_id | product_suppliers.supplier_id = suppliers.supplier_id | staff_department_assignments.staff_id = staff.staff_id | staff_department_assignments.department_id = departments.department_id | 

### Response:

select product_name , product_id from products where product_price between 600 and 700
### Instruction:

Convert text to sql: What are the names and ids of products costing between 600 and 700? | addresses : address_id , address_details | staff : staff_id , staff_gender , staff_name | suppliers : supplier_id , supplier_name , supplier_phone | department_store_chain : dept_store_chain_id , dept_store_chain_name | customers : customer_id , payment_method_code , customer_code , customer_name , customer_address , customer_phone , customer_email | products : product_id , product_type_code , product_name , product_price | supplier_addresses : supplier_id , address_id , date_from , date_to | customer_addresses : customer_id , address_id , date_from , date_to | customer_orders : order_id , customer_id , order_status_code , order_date | department_stores : dept_store_id , dept_store_chain_id , store_name , store_address , store_phone , store_email | departments : department_id , dept_store_id , department_name | order_items : order_item_id , order_id , product_id | product_suppliers : product_id , supplier_id , date_supplied_from , date_supplied_to , total_amount_purchased , total_value_purchased | staff_department_assignments : staff_id , department_id , date_assigned_from , job_title_code , date_assigned_to | supplier_addresses.supplier_id = suppliers.supplier_id | supplier_addresses.address_id = addresses.address_id | customer_addresses.customer_id = customers.customer_id | customer_addresses.address_id = addresses.address_id | customer_orders.customer_id = customers.customer_id | department_stores.dept_store_chain_id = department_store_chain.dept_store_chain_id | departments.dept_store_id = department_stores.dept_store_id | order_items.product_id = products.product_id | order_items.order_id = customer_orders.order_id | product_suppliers.product_id = products.product_id | product_suppliers.supplier_id = suppliers.supplier_id | staff_department_assignments.staff_id = staff.staff_id | staff_department_assignments.department_id = departments.department_id | 

### Response:

select product_name , product_id from products where product_price between 600 and 700
### Instruction:

Convert text to sql: Find the ids of all distinct customers who made order after some orders that were Cancelled. | addresses : address_id , address_details | staff : staff_id , staff_gender , staff_name | suppliers : supplier_id , supplier_name , supplier_phone | department_store_chain : dept_store_chain_id , dept_store_chain_name | customers : customer_id , payment_method_code , customer_code , customer_name , customer_address , customer_phone , customer_email | products : product_id , product_type_code , product_name , product_price | supplier_addresses : supplier_id , address_id , date_from , date_to | customer_addresses : customer_id , address_id , date_from , date_to | customer_orders : order_id , customer_id , order_status_code , order_date | department_stores : dept_store_id , dept_store_chain_id , store_name , store_address , store_phone , store_email | departments : department_id , dept_store_id , department_name | order_items : order_item_id , order_id , product_id | product_suppliers : product_id , supplier_id , date_supplied_from , date_supplied_to , total_amount_purchased , total_value_purchased | staff_department_assignments : staff_id , department_id , date_assigned_from , job_title_code , date_assigned_to | supplier_addresses.supplier_id = suppliers.supplier_id | supplier_addresses.address_id = addresses.address_id | customer_addresses.customer_id = customers.customer_id | customer_addresses.address_id = addresses.address_id | customer_orders.customer_id = customers.customer_id | department_stores.dept_store_chain_id = department_store_chain.dept_store_chain_id | departments.dept_store_id = department_stores.dept_store_id | order_items.product_id = products.product_id | order_items.order_id = customer_orders.order_id | product_suppliers.product_id = products.product_id | product_suppliers.supplier_id = suppliers.supplier_id | staff_department_assignments.staff_id = staff.staff_id | staff_department_assignments.department_id = departments.department_id | 

### Response:

select distinct customer_id from customer_orders where order_date > ( select min ( order_date ) from customer_orders where order_status_code = 'Cancelled' )
### Instruction:

Convert text to sql: What are the distinct ids of customers who made an order after any order that was Cancelled? | addresses : address_id , address_details | staff : staff_id , staff_gender , staff_name | suppliers : supplier_id , supplier_name , supplier_phone | department_store_chain : dept_store_chain_id , dept_store_chain_name | customers : customer_id , payment_method_code , customer_code , customer_name , customer_address , customer_phone , customer_email | products : product_id , product_type_code , product_name , product_price | supplier_addresses : supplier_id , address_id , date_from , date_to | customer_addresses : customer_id , address_id , date_from , date_to | customer_orders : order_id , customer_id , order_status_code , order_date | department_stores : dept_store_id , dept_store_chain_id , store_name , store_address , store_phone , store_email | departments : department_id , dept_store_id , department_name | order_items : order_item_id , order_id , product_id | product_suppliers : product_id , supplier_id , date_supplied_from , date_supplied_to , total_amount_purchased , total_value_purchased | staff_department_assignments : staff_id , department_id , date_assigned_from , job_title_code , date_assigned_to | supplier_addresses.supplier_id = suppliers.supplier_id | supplier_addresses.address_id = addresses.address_id | customer_addresses.customer_id = customers.customer_id | customer_addresses.address_id = addresses.address_id | customer_orders.customer_id = customers.customer_id | department_stores.dept_store_chain_id = department_store_chain.dept_store_chain_id | departments.dept_store_id = department_stores.dept_store_id | order_items.product_id = products.product_id | order_items.order_id = customer_orders.order_id | product_suppliers.product_id = products.product_id | product_suppliers.supplier_id = suppliers.supplier_id | staff_department_assignments.staff_id = staff.staff_id | staff_department_assignments.department_id = departments.department_id | 

### Response:

select distinct customer_id from customer_orders where order_date > ( select min ( order_date ) from customer_orders where order_status_code = 'Cancelled' )