cnatale/presto-athena-txt-2-sql huggingface dataset:
Which customer made the largest amount of claim in a single claim? Return the customer details.
Additional table information: table: insurance_and_eClaims
SQL: SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_claimed = (SELECT MAX(amount_claimed) FROM claim_headers)
What is the name of the customer who has made the minimum amount of payment in one claim?
Additional table information: table: insurance_and_eClaims
SQL: SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_piad = (SELECT MIN(amount_piad) FROM claim_headers)
Which customer made the smallest amount of claim in one claim? Return the customer details.
Additional table information: table: insurance_and_eClaims
SQL: SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_piad = (SELECT MIN(amount_piad) FROM claim_headers)
Find the names of customers who have no policies associated.
Additional table information: table: insurance_and_eClaims
SQL: SELECT customer_details FROM customers EXCEPT SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id
What are the names of customers who do not have any policies?
Additional table information: table: insurance_and_eClaims
SQL: SELECT customer_details FROM customers EXCEPT SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id
How many claim processing stages are there in total?
Additional table information: table: insurance_and_eClaims
SQL: SELECT COUNT(*) FROM claims_processing_stages
Find the number of distinct stages in claim processing.
Additional table information: table: insurance_and_eClaims
SQL: SELECT COUNT(*) FROM claims_processing_stages
What is the name of the claim processing stage that most of the claims are on?
Additional table information: table: insurance_and_eClaims
SQL: SELECT t2.claim_status_name FROM claims_processing AS t1 JOIN claims_processing_stages AS t2 ON t1.claim_stage_id = t2.claim_stage_id GROUP BY t1.claim_stage_id ORDER BY COUNT(*) DESC LIMIT 1
Which claim processing stage has the most claims? Show the claim status name.
Additional table information: table: insurance_and_eClaims
SQL: SELECT t2.claim_status_name FROM claims_processing AS t1 JOIN claims_processing_stages AS t2 ON t1.claim_stage_id = t2.claim_stage_id GROUP BY t1.claim_stage_id ORDER BY COUNT(*) DESC LIMIT 1
Find the names of customers whose name contains 'Diana'.
Additional table information: table: insurance_and_eClaims
SQL: SELECT customer_details FROM customers WHERE customer_details LIKE '%Diana%'
Which customers have the substring 'Diana' in their names? Return the customer details.
Additional table information: table: insurance_and_eClaims
SQL: SELECT customer_details FROM customers WHERE customer_details LIKE '%Diana%'
Find the names of the customers who have an deputy policy.
Additional table information: table: insurance_and_eClaims
SQL: SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = 'Deputy'
Which customers have an insurance policy with the type code 'Deputy'? Give me the customer details.
Additional table information: table: insurance_and_eClaims
SQL: SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = 'Deputy'
Find the names of customers who either have an deputy policy or uniformed policy.
Additional table information: table: insurance_and_eClaims
SQL: SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = 'Deputy' OR t1.policy_type_code = 'Uniform'
Which customers have an insurance policy with the type code 'Deputy' or 'Uniform'? Return the customer details.
Additional table information: table: insurance_and_eClaims
SQL: SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = 'Deputy' OR t1.policy_type_code = 'Uniform'
Find the names of all the customers and staff members.
Additional table information: table: insurance_and_eClaims
SQL: SELECT customer_details FROM customers UNION SELECT staff_details FROM staff
What are the names of the customers and staff members?
Additional table information: table: insurance_and_eClaims
SQL: SELECT customer_details FROM customers UNION SELECT staff_details FROM staff
Find the number of records of each policy type and its type code.
Additional table information: table: insurance_and_eClaims
SQL: SELECT policy_type_code, COUNT(*) FROM policies GROUP BY policy_type_code
For each policy type, return its type code and its count in the record.
Additional table information: table: insurance_and_eClaims
SQL: SELECT policy_type_code, COUNT(*) FROM policies GROUP BY policy_type_code
Find the name of the customer that has been involved in the most policies.
Additional table information: table: insurance_and_eClaims
SQL: SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t2.customer_details ORDER BY COUNT(*) DESC LIMIT 1
Which customer have the most policies? Give me the customer details.
Additional table information: table: insurance_and_eClaims
SQL: SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t2.customer_details ORDER BY COUNT(*) DESC LIMIT 1
What is the description of the claim status 'Open'?
Additional table information: table: insurance_and_eClaims
SQL: SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name = 'Open'
Find the description of the claim status 'Open'.
Additional table information: table: insurance_and_eClaims
SQL: SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name = 'Open'
How many distinct claim outcome codes are there?
Additional table information: table: insurance_and_eClaims
SQL: SELECT COUNT(DISTINCT claim_outcome_code) FROM claims_processing
Count the number of distinct claim outcome codes.
Additional table information: table: insurance_and_eClaims
SQL: SELECT COUNT(DISTINCT claim_outcome_code) FROM claims_processing
Which customer is associated with the latest policy?
Additional table information: table: insurance_and_eClaims
SQL: SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.start_date = (SELECT MAX(start_date) FROM policies)
Find the customer who started a policy most recently.
Additional table information: table: insurance_and_eClaims
SQL: SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.start_date = (SELECT MAX(start_date) FROM policies)
Show the number of accounts.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM Accounts
How many accounts are there?
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM Accounts
How many customers have opened an account?
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(DISTINCT customer_id) FROM Accounts
Count the number of customers who have an account.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(DISTINCT customer_id) FROM Accounts
Show the id, the date of account opened, the account name, and other account detail for all accounts.
Additional table information: table: customers_and_invoices
SQL: SELECT account_id, date_account_opened, account_name, other_account_details FROM Accounts
What are the ids, date opened, name, and other details for all accounts?
Additional table information: table: customers_and_invoices
SQL: SELECT account_id, date_account_opened, account_name, other_account_details FROM Accounts
Show the id, the account name, and other account details for all accounts by the customer with first name 'Meaghan'.
Additional table information: table: customers_and_invoices
SQL: SELECT T1.account_id, T1.date_account_opened, T1.account_name, T1.other_account_details FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = 'Meaghan'
What are the ids, names, dates of opening, and other details for accounts corresponding to the customer with the first name 'Meaghan'?
Additional table information: table: customers_and_invoices
SQL: SELECT T1.account_id, T1.date_account_opened, T1.account_name, T1.other_account_details FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = 'Meaghan'
Show the account name and other account detail for all accounts by the customer with first name Meaghan and last name Keeling.
Additional table information: table: customers_and_invoices
SQL: SELECT T1.account_name, T1.other_account_details FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = 'Meaghan' AND T2.customer_last_name = 'Keeling'
What are the names and other details for accounts corresponding to the customer named Meaghan Keeling?
Additional table information: table: customers_and_invoices
SQL: SELECT T1.account_name, T1.other_account_details FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = 'Meaghan' AND T2.customer_last_name = 'Keeling'
Show the first name and last name for the customer with account name 900.
Additional table information: table: customers_and_invoices
SQL: SELECT T2.customer_first_name, T2.customer_last_name FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.account_name = '900'
What are the full names of customers with the account name 900?
Additional table information: table: customers_and_invoices
SQL: SELECT T2.customer_first_name, T2.customer_last_name FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.account_name = '900'
How many customers don't have an account?
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM Customers WHERE NOT customer_id IN (SELECT customer_id FROM Accounts)
Count the number of customers who do not have an account.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM Customers WHERE NOT customer_id IN (SELECT customer_id FROM Accounts)
Show the unique first names, last names, and phone numbers for all customers with any account.
Additional table information: table: customers_and_invoices
SQL: SELECT DISTINCT T1.customer_first_name, T1.customer_last_name, T1.phone_number FROM Customers AS T1 JOIN Accounts AS T2 ON T1.customer_id = T2.customer_id
What are the distinct first names, last names, and phone numbers for customers with accounts?
Additional table information: table: customers_and_invoices
SQL: SELECT DISTINCT T1.customer_first_name, T1.customer_last_name, T1.phone_number FROM Customers AS T1 JOIN Accounts AS T2 ON T1.customer_id = T2.customer_id
Show customer ids who don't have an account.
Additional table information: table: customers_and_invoices
SQL: SELECT customer_id FROM Customers EXCEPT SELECT customer_id FROM Accounts
What are the customer ids for customers who do not have an account?
Additional table information: table: customers_and_invoices
SQL: SELECT customer_id FROM Customers EXCEPT SELECT customer_id FROM Accounts
How many accounts does each customer have? List the number and customer id.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*), customer_id FROM Accounts GROUP BY customer_id
Count the number of accounts corresponding to each customer id.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*), customer_id FROM Accounts GROUP BY customer_id
What is the customer id, first and last name with most number of accounts.
Additional table information: table: customers_and_invoices
SQL: SELECT T1.customer_id, T2.customer_first_name, T2.customer_last_name FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC LIMIT 1
Return the id and full name of the customer with the most accounts.
Additional table information: table: customers_and_invoices
SQL: SELECT T1.customer_id, T2.customer_first_name, T2.customer_last_name FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC LIMIT 1
Show id, first name and last name for all customers and the number of accounts.
Additional table information: table: customers_and_invoices
SQL: SELECT T1.customer_id, T2.customer_first_name, T2.customer_last_name, COUNT(*) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id
What are the the full names and ids for all customers, and how many accounts does each have?
Additional table information: table: customers_and_invoices
SQL: SELECT T1.customer_id, T2.customer_first_name, T2.customer_last_name, COUNT(*) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id
Show first name and id for all customers with at least 2 accounts.
Additional table information: table: customers_and_invoices
SQL: SELECT T2.customer_first_name, T1.customer_id FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING COUNT(*) >= 2
What are the first names and ids for customers who have two or more accounts?
Additional table information: table: customers_and_invoices
SQL: SELECT T2.customer_first_name, T1.customer_id FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING COUNT(*) >= 2
Show the number of customers.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM Customers
Count the number of customers.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM Customers
Show the number of customers for each gender.
Additional table information: table: customers_and_invoices
SQL: SELECT gender, COUNT(*) FROM Customers GROUP BY gender
How many customers are there of each gender?
Additional table information: table: customers_and_invoices
SQL: SELECT gender, COUNT(*) FROM Customers GROUP BY gender
How many transactions do we have?
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM Financial_transactions
Count the number of transactions.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM Financial_transactions
How many transaction does each account have? Show the number and account id.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*), account_id FROM Financial_transactions
Count the number of financial transactions that correspond to each account id.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*), account_id FROM Financial_transactions
How many transaction does account with name 337 have?
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id WHERE T2.account_name = '337'
Count the number of financial transactions that the account with the name 337 has.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id WHERE T2.account_name = '337'
What is the average, minimum, maximum, and total transaction amount?
Additional table information: table: customers_and_invoices
SQL: SELECT AVG(transaction_amount), MIN(transaction_amount), MAX(transaction_amount), SUM(transaction_amount) FROM Financial_transactions
Return the average, minimum, maximum, and total transaction amounts.
Additional table information: table: customers_and_invoices
SQL: SELECT AVG(transaction_amount), MIN(transaction_amount), MAX(transaction_amount), SUM(transaction_amount) FROM Financial_transactions
Show ids for all transactions whose amounts are greater than the average.
Additional table information: table: customers_and_invoices
SQL: SELECT transaction_id FROM Financial_transactions WHERE transaction_amount > (SELECT AVG(transaction_amount) FROM Financial_transactions)
What are the ids for transactions that have an amount greater than the average amount of a transaction?
Additional table information: table: customers_and_invoices
SQL: SELECT transaction_id FROM Financial_transactions WHERE transaction_amount > (SELECT AVG(transaction_amount) FROM Financial_transactions)
Show the transaction types and the total amount of transactions.
Additional table information: table: customers_and_invoices
SQL: SELECT transaction_type, SUM(transaction_amount) FROM Financial_transactions GROUP BY transaction_type
What are total transaction amounts for each transaction type?
Additional table information: table: customers_and_invoices
SQL: SELECT transaction_type, SUM(transaction_amount) FROM Financial_transactions GROUP BY transaction_type
Show the account name, id and the number of transactions for each account.
Additional table information: table: customers_and_invoices
SQL: SELECT T2.account_name, T1.account_id, COUNT(*) FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id GROUP BY T1.account_id
Return the names and ids of each account, as well as the number of transactions.
Additional table information: table: customers_and_invoices
SQL: SELECT T2.account_name, T1.account_id, COUNT(*) FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id GROUP BY T1.account_id
Show the account id with most number of transactions.
Additional table information: table: customers_and_invoices
SQL: SELECT account_id FROM Financial_transactions GROUP BY account_id ORDER BY COUNT(*) DESC LIMIT 1
What is the id of the account with the most transactions?
Additional table information: table: customers_and_invoices
SQL: SELECT account_id FROM Financial_transactions GROUP BY account_id ORDER BY COUNT(*) DESC LIMIT 1
Show the account id and name with at least 4 transactions.
Additional table information: table: customers_and_invoices
SQL: SELECT T1.account_id, T2.account_name FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id GROUP BY T1.account_id HAVING COUNT(*) >= 4
What are the ids and names of accounts with 4 or more transactions?
Additional table information: table: customers_and_invoices
SQL: SELECT T1.account_id, T2.account_name FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id GROUP BY T1.account_id HAVING COUNT(*) >= 4
Show all product sizes.
Additional table information: table: customers_and_invoices
SQL: SELECT DISTINCT product_size FROM Products
What are the different product sizes?
Additional table information: table: customers_and_invoices
SQL: SELECT DISTINCT product_size FROM Products
Show all product colors.
Additional table information: table: customers_and_invoices
SQL: SELECT DISTINCT product_color FROM Products
What are the different product colors?
Additional table information: table: customers_and_invoices
SQL: SELECT DISTINCT product_color FROM Products
Show the invoice number and the number of transactions for each invoice.
Additional table information: table: customers_and_invoices
SQL: SELECT invoice_number, COUNT(*) FROM Financial_transactions GROUP BY invoice_number
How many transactions correspond to each invoice number?
Additional table information: table: customers_and_invoices
SQL: SELECT invoice_number, COUNT(*) FROM Financial_transactions GROUP BY invoice_number
What is the invoice number and invoice date for the invoice with most number of transactions?
Additional table information: table: customers_and_invoices
SQL: SELECT T2.invoice_number, T2.invoice_date FROM Financial_transactions AS T1 JOIN Invoices AS T2 ON T1.invoice_number = T2.invoice_number GROUP BY T1.invoice_number ORDER BY COUNT(*) DESC LIMIT 1
What is the invoice number and invoice date corresponding to the invoice with the greatest number of transactions?
Additional table information: table: customers_and_invoices
SQL: SELECT T2.invoice_number, T2.invoice_date FROM Financial_transactions AS T1 JOIN Invoices AS T2 ON T1.invoice_number = T2.invoice_number GROUP BY T1.invoice_number ORDER BY COUNT(*) DESC LIMIT 1
How many invoices do we have?
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM Invoices
Count the number of invoices.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM Invoices
Show invoice dates and order id and details for all invoices.
Additional table information: table: customers_and_invoices
SQL: SELECT T1.invoice_date, T1.order_id, T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id
What are the invoice dates, order ids, and order details for all invoices?
Additional table information: table: customers_and_invoices
SQL: SELECT T1.invoice_date, T1.order_id, T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id
Show the order ids and the number of invoices for each order.
Additional table information: table: customers_and_invoices
SQL: SELECT order_id, COUNT(*) FROM Invoices GROUP BY order_id
How many invoices correspond to each order id?
Additional table information: table: customers_and_invoices
SQL: SELECT order_id, COUNT(*) FROM Invoices GROUP BY order_id
What is the order id and order details for the order more than two invoices.
Additional table information: table: customers_and_invoices
SQL: SELECT T2.order_id, T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id GROUP BY T2.order_id HAVING COUNT(*) > 2
Return the order ids and details for orderes with two or more invoices.
Additional table information: table: customers_and_invoices
SQL: SELECT T2.order_id, T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id GROUP BY T2.order_id HAVING COUNT(*) > 2
What is the customer last name, id and phone number with most number of orders?
Additional table information: table: customers_and_invoices
SQL: SELECT T2.customer_last_name, T1.customer_id, T2.phone_number FROM Orders AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC LIMIT 1
Return the last name, id and phone number of the customer who has made the greatest number of orders.
Additional table information: table: customers_and_invoices
SQL: SELECT T2.customer_last_name, T1.customer_id, T2.phone_number FROM Orders AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC LIMIT 1
Show all product names without an order.
Additional table information: table: customers_and_invoices
SQL: SELECT product_name FROM Products EXCEPT SELECT T1.product_name FROM Products AS T1 JOIN Order_items AS T2 ON T1.product_id = T2.product_id
What are the names of products that have never been ordered?
Additional table information: table: customers_and_invoices
SQL: SELECT product_name FROM Products EXCEPT SELECT T1.product_name FROM Products AS T1 JOIN Order_items AS T2 ON T1.product_id = T2.product_id
Show all product names and the total quantity ordered for each product name.
Additional table information: table: customers_and_invoices
SQL: SELECT T2.product_name, SUM(T1.product_quantity) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name
What are the different product names, and what is the sum of quantity ordered for each product?
Additional table information: table: customers_and_invoices
SQL: SELECT T2.product_name, SUM(T1.product_quantity) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name
Show the order ids and the number of items in each order.
Additional table information: table: customers_and_invoices
SQL: SELECT order_id, COUNT(*) FROM Order_items GROUP BY order_id
How many order items correspond to each order id?
Additional table information: table: customers_and_invoices
SQL: SELECT order_id, COUNT(*) FROM Order_items GROUP BY order_id
Show the product ids and the number of unique orders containing each product.
Additional table information: table: customers_and_invoices
SQL: SELECT product_id, COUNT(DISTINCT order_id) FROM Order_items GROUP BY product_id
How many distinct order ids correspond to each product?
Additional table information: table: customers_and_invoices
SQL: SELECT product_id, COUNT(DISTINCT order_id) FROM Order_items GROUP BY product_id
Show all product names and the number of customers having an order on each product.
Additional table information: table: customers_and_invoices
SQL: SELECT T2.product_name, COUNT(*) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id JOIN Orders AS T3 ON T3.order_id = T1.order_id GROUP BY T2.product_name
What are teh names of the different products, as well as the number of customers who have ordered each product.
Additional table information: table: customers_and_invoices
SQL: SELECT T2.product_name, COUNT(*) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id JOIN Orders AS T3 ON T3.order_id = T1.order_id GROUP BY T2.product_name
Show order ids and the number of products in each order.
Additional table information: table: customers_and_invoices
SQL: SELECT order_id, COUNT(DISTINCT product_id) FROM Order_items GROUP BY order_id
How many different products correspond to each order id?
Additional table information: table: customers_and_invoices
SQL: SELECT order_id, COUNT(DISTINCT product_id) FROM Order_items GROUP BY order_id
Show order ids and the total quantity in each order.
Additional table information: table: customers_and_invoices
SQL: SELECT order_id, SUM(product_quantity) FROM Order_items GROUP BY order_id
Give the order ids for all orders, as well as the total product quantity in each.
Additional table information: table: customers_and_invoices
SQL: SELECT order_id, SUM(product_quantity) FROM Order_items GROUP BY order_id
How many products were not included in any order?
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM products WHERE NOT product_id IN (SELECT product_id FROM Order_items)
Count the number of products that were never ordered.
Additional table information: table: customers_and_invoices
SQL: SELECT COUNT(*) FROM products WHERE NOT product_id IN (SELECT product_id FROM Order_items)
How many churches opened before 1850 are there?
Additional table information: table: wedding
SQL: SELECT COUNT(*) FROM Church WHERE Open_Date < 1850
Show the name, open date, and organizer for all churches.
Additional table information: table: wedding
SQL: SELECT name, open_date, organized_by FROM Church
List all church names in descending order of opening date.
Additional table information: table: wedding
SQL: SELECT name FROM church ORDER BY open_date DESC
Show the opening year in whcih at least two churches opened.
Additional table information: table: wedding
SQL: SELECT open_date FROM church GROUP BY open_date HAVING COUNT(*) >= 2
Show the organizer and name for churches that opened between 1830 and 1840.
Additional table information: table: wedding
SQL: SELECT organized_by, name FROM church WHERE open_date BETWEEN 1830 AND 1840
Show all opening years and the number of churches that opened in that year.
Additional table information: table: wedding
SQL: SELECT open_date, COUNT(*) FROM church GROUP BY open_date
Show the name and opening year for three churches that opened most recently.
Additional table information: table: wedding
SQL: SELECT name, open_date FROM church ORDER BY open_date DESC LIMIT 3
How many female people are older than 30 in our record?
Additional table information: table: wedding
SQL: SELECT COUNT(*) FROM people WHERE is_male = 'F' AND age > 30
Show the country where people older than 30 and younger than 25 are from.
Additional table information: table: wedding
SQL: SELECT country FROM people WHERE age < 25 INTERSECT SELECT country FROM people WHERE age > 30
Show the minimum, maximum, and average age for all people.
Additional table information: table: wedding
SQL: SELECT MIN(age), MAX(age), AVG(age) FROM people
Show the name and country for all people whose age is smaller than the average.
Additional table information: table: wedding
SQL: SELECT name, country FROM people WHERE age < (SELECT AVG(age) FROM people)
Show the pair of male and female names in all weddings after year 2014
Additional table information: table: wedding
SQL: SELECT T2.name, T3.name FROM wedding AS T1 JOIN people AS T2 ON T1.male_id = T2.people_id JOIN people AS T3 ON T1.female_id = T3.people_id WHERE T1.year > 2014
Show the name and age for all male people who don't have a wedding.
Additional table information: table: wedding
SQL: SELECT name, age FROM people WHERE is_male = 'T' AND NOT people_id IN (SELECT male_id FROM wedding)
Show all church names except for those that had a wedding in year 2015.
Additional table information: table: wedding
SQL: SELECT name FROM church EXCEPT SELECT T1.name FROM church AS T1 JOIN wedding AS T2 ON T1.church_id = T2.church_id WHERE T2.year = 2015
Show all church names that have hosted least two weddings.
Additional table information: table: wedding
SQL: SELECT T1.name FROM church AS T1 JOIN wedding AS T2 ON T1.church_id = T2.church_id GROUP BY T1.church_id HAVING COUNT(*) >= 2
Show the names for all females from Canada having a wedding in year 2016.
Additional table information: table: wedding
SQL: SELECT T2.name FROM wedding AS T1 JOIN people AS T2 ON T1.female_id = T2.people_id WHERE T1.year = 2016 AND T2.is_male = 'F' AND T2.country = 'Canada'
How many weddings are there in year 2016?
Additional table information: table: wedding
SQL: SELECT COUNT(*) FROM wedding WHERE YEAR = 2016
Show the church names for the weddings of all people older than 30.
Additional table information: table: wedding
SQL: SELECT T4.name FROM wedding AS T1 JOIN people AS T2 ON T1.male_id = T2.people_id JOIN people AS T3 ON T1.female_id = T3.people_id JOIN church AS T4 ON T4.church_id = T1.church_id WHERE T2.age > 30 OR T3.age > 30
Show all countries and the number of people from each country.
Additional table information: table: wedding
SQL: SELECT country, COUNT(*) FROM people GROUP BY country
How many churches have a wedding in year 2016?
Additional table information: table: wedding
SQL: SELECT COUNT(DISTINCT church_id) FROM wedding WHERE YEAR = 2016
How many artists do we have?
Additional table information: table: theme_gallery
SQL: SELECT COUNT(*) FROM artist
Count the number of artists.
Additional table information: table: theme_gallery
SQL: SELECT COUNT(*) FROM artist
Show all artist name, age, and country ordered by the yeared they joined.
Additional table information: table: theme_gallery
SQL: SELECT name, age, country FROM artist ORDER BY Year_Join NULLS FIRST
What are the names, ages, and countries of artists, sorted by the year they joined?
Additional table information: table: theme_gallery
SQL: SELECT name, age, country FROM artist ORDER BY Year_Join NULLS FIRST
What are all distinct country for artists?
Additional table information: table: theme_gallery
SQL: SELECT DISTINCT country FROM artist
Return the different countries for artists.
Additional table information: table: theme_gallery
SQL: SELECT DISTINCT country FROM artist
Show all artist names and the year joined who are not from United States.
Additional table information: table: theme_gallery
SQL: SELECT name, year_join FROM artist WHERE country <> 'United States'
What are the names and year of joining for artists that do not have the country 'United States'?
Additional table information: table: theme_gallery
SQL: SELECT name, year_join FROM artist WHERE country <> 'United States'
How many artists are above age 46 and joined after 1990?
Additional table information: table: theme_gallery
SQL: SELECT COUNT(*) FROM artist WHERE age > 46 AND year_join > 1990
Count the number of artists who are older than 46 and joined after 1990.
Additional table information: table: theme_gallery
SQL: SELECT COUNT(*) FROM artist WHERE age > 46 AND year_join > 1990
What is the average and minimum age of all artists from United States.
Additional table information: table: theme_gallery
SQL: SELECT AVG(age), MIN(age) FROM artist WHERE country = 'United States'
Return the average and minimum ages across artists from the United States.
Additional table information: table: theme_gallery
SQL: SELECT AVG(age), MIN(age) FROM artist WHERE country = 'United States'
What is the name of the artist who joined latest?
Additional table information: table: theme_gallery
SQL: SELECT name FROM artist ORDER BY year_join DESC LIMIT 1
Return the name of the artist who has the latest join year.
Additional table information: table: theme_gallery
SQL: SELECT name FROM artist ORDER BY year_join DESC LIMIT 1
How many exhibition are there in year 2005 or after?
Additional table information: table: theme_gallery
SQL: SELECT COUNT(*) FROM exhibition WHERE YEAR >= 2005
Count the number of exhibitions that happened in or after 2005.
Additional table information: table: theme_gallery
SQL: SELECT COUNT(*) FROM exhibition WHERE YEAR >= 2005
Show theme and year for all exhibitions with ticket prices lower than 15.
Additional table information: table: theme_gallery
SQL: SELECT theme, YEAR FROM exhibition WHERE ticket_price < 15
What are the theme and year for all exhibitions that have a ticket price under 15?
Additional table information: table: theme_gallery
SQL: SELECT theme, YEAR FROM exhibition WHERE ticket_price < 15
Show all artist names and the number of exhibitions for each artist.
Additional table information: table: theme_gallery
SQL: SELECT T2.name, COUNT(*) FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id
How many exhibitions has each artist had?
Additional table information: table: theme_gallery
SQL: SELECT T2.name, COUNT(*) FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id
What is the name and country for the artist with most number of exhibitions?
Additional table information: table: theme_gallery
SQL: SELECT T2.name, T2.country FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id ORDER BY COUNT(*) DESC LIMIT 1
Return the name and country corresponding to the artist who has had the most exhibitions.
Additional table information: table: theme_gallery
SQL: SELECT T2.name, T2.country FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id ORDER BY COUNT(*) DESC LIMIT 1
Show names for artists without any exhibition.
Additional table information: table: theme_gallery
SQL: SELECT name FROM artist WHERE NOT artist_id IN (SELECT artist_id FROM exhibition)
What are the names of artists that have not had any exhibitions?
Additional table information: table: theme_gallery
SQL: SELECT name FROM artist WHERE NOT artist_id IN (SELECT artist_id FROM exhibition)
What is the theme and artist name for the exhibition with a ticket price higher than the average?
Additional table information: table: theme_gallery
SQL: SELECT T1.theme, T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.ticket_price > (SELECT AVG(ticket_price) FROM exhibition)
Return the names of artists and the themes of their exhibitions that had a ticket price higher than average.
Additional table information: table: theme_gallery
SQL: SELECT T1.theme, T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.ticket_price > (SELECT AVG(ticket_price) FROM exhibition)
Show the average, minimum, and maximum ticket prices for exhibitions for all years before 2009.
Additional table information: table: theme_gallery
SQL: SELECT AVG(ticket_price), MIN(ticket_price), MAX(ticket_price) FROM exhibition WHERE YEAR < 2009
What are the average, minimum, and maximum ticket prices for exhibitions that happened prior to 2009?
Additional table information: table: theme_gallery
SQL: SELECT AVG(ticket_price), MIN(ticket_price), MAX(ticket_price) FROM exhibition WHERE YEAR < 2009
Show theme and year for all exhibitions in an descending order of ticket price.
Additional table information: table: theme_gallery
SQL: SELECT theme, YEAR FROM exhibition ORDER BY ticket_price DESC
What are the themes and years for exhibitions, sorted by ticket price descending?
Additional table information: table: theme_gallery
SQL: SELECT theme, YEAR FROM exhibition ORDER BY ticket_price DESC
What is the theme, date, and attendance for the exhibition in year 2004?
Additional table information: table: theme_gallery
SQL: SELECT T2.theme, T1.date, T1.attendance FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T2.year = 2004
Return the themes, dates, and attendance for exhibitions that happened in 2004.
Additional table information: table: theme_gallery
SQL: SELECT T2.theme, T1.date, T1.attendance FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T2.year = 2004
Show all artist names who didn't have an exhibition in 2004.
Additional table information: table: theme_gallery
SQL: SELECT name FROM artist EXCEPT SELECT T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.year = 2004
What are the names of artists who did not have an exhibition in 2004?
Additional table information: table: theme_gallery
SQL: SELECT name FROM artist EXCEPT SELECT T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.year = 2004
Show the theme for exhibitions with both records of an attendance below 100 and above 500.
Additional table information: table: theme_gallery
SQL: SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance < 100 INTERSECT SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 500
Which themes have had corresponding exhibitions that have had attendance both below 100 and above 500?
Additional table information: table: theme_gallery
SQL: SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance < 100 INTERSECT SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 500
How many exhibitions have a attendance more than 100 or have a ticket price below 10?
Additional table information: table: theme_gallery
SQL: SELECT COUNT(*) FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 100 OR T2.ticket_price < 10
Count the number of exhibitions that have had an attendnance of over 100 or a ticket prices under 10.
Additional table information: table: theme_gallery
SQL: SELECT COUNT(*) FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 100 OR T2.ticket_price < 10
Show all artist names with an average exhibition attendance over 200.
Additional table information: table: theme_gallery
SQL: SELECT T3.name FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id JOIN artist AS T3 ON T3.artist_id = T2.artist_id GROUP BY T3.artist_id HAVING AVG(T1.attendance) > 200
What are the names of artist whose exhibitions draw over 200 attendees on average?
Additional table information: table: theme_gallery
SQL: SELECT T3.name FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id JOIN artist AS T3 ON T3.artist_id = T2.artist_id GROUP BY T3.artist_id HAVING AVG(T1.attendance) > 200
Find the id of the item whose title is 'orange'.
Additional table information: table: epinions_1
SQL: SELECT i_id FROM item WHERE title = 'orange'
List all information in the item table.
Additional table information: table: epinions_1
SQL: SELECT * FROM item
Find the number of reviews.
Additional table information: table: epinions_1
SQL: SELECT COUNT(*) FROM review
How many users are there?
Additional table information: table: epinions_1
SQL: SELECT COUNT(*) FROM useracct
Find the average and maximum rating of all reviews.
Additional table information: table: epinions_1
SQL: SELECT AVG(rating), MAX(rating) FROM review
Find the highest rank of all reviews.
Additional table information: table: epinions_1
SQL: SELECT MIN(rank) FROM review
How many different users wrote some reviews?
Additional table information: table: epinions_1
SQL: SELECT COUNT(DISTINCT u_id) FROM review
How many different items were reviewed by some users?
Additional table information: table: epinions_1
SQL: SELECT COUNT(DISTINCT i_id) FROM review
Find the number of items that did not receive any review.
Additional table information: table: epinions_1
SQL: SELECT COUNT(*) FROM item WHERE NOT i_id IN (SELECT i_id FROM review)
Find the names of users who did not leave any review.
Additional table information: table: epinions_1
SQL: SELECT name FROM useracct WHERE NOT u_id IN (SELECT u_id FROM review)
Find the names of goods that receive a rating of 10.
Additional table information: table: epinions_1
SQL: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating = 10
Find the titles of items whose rating is higher than the average review rating of all items.
Additional table information: table: epinions_1
SQL: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating > (SELECT AVG(rating) FROM review)
Find the titles of items that received any rating below 5.
Additional table information: table: epinions_1
SQL: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating < 5
Find the titles of items that received both a rating higher than 8 and a rating below 5.
Additional table information: table: epinions_1
SQL: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating > 8 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating < 5
Find the names of items whose rank is higher than 3 and whose average rating is above 5.
Additional table information: table: epinions_1
SQL: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rank > 3 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id HAVING AVG(T2.rating) > 5
Find the name of the item with the lowest average rating.
Additional table information: table: epinions_1
SQL: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id ORDER BY AVG(T2.rating) NULLS FIRST LIMIT 1
List the titles of all items in alphabetic order .
Additional table information: table: epinions_1
SQL: SELECT title FROM item ORDER BY title NULLS FIRST
Find the name of the user who gives the most reviews.
Additional table information: table: epinions_1
SQL: SELECT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id GROUP BY T2.u_id ORDER BY COUNT(*) DESC LIMIT 1
Find the name and id of the item with the highest average rating.
Additional table information: table: epinions_1
SQL: SELECT T1.title, T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id ORDER BY AVG(T2.rating) DESC LIMIT 1
Find the name and id of the good with the highest average rank.
Additional table information: table: epinions_1
SQL: SELECT T1.title, T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id ORDER BY AVG(T2.rank) DESC LIMIT 1
For each user, return the name and the average rating of reviews given by them.
Additional table information: table: epinions_1
SQL: SELECT T1.name, AVG(T2.rating) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id GROUP BY T2.u_id
For each user, find their name and the number of reviews written by them.
Additional table information: table: epinions_1
SQL: SELECT T1.name, COUNT(*) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id GROUP BY T2.u_id
Find the name of the user who gave the highest rating.
Additional table information: table: epinions_1
SQL: SELECT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id ORDER BY T2.rating DESC LIMIT 1
Find the name of the source user with the highest average trust score.
Additional table information: table: epinions_1
SQL: SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id = T2.source_u_id GROUP BY T2.source_u_id ORDER BY AVG(trust) DESC LIMIT 1
Find each target user's name and average trust score.
Additional table information: table: epinions_1
SQL: SELECT T1.name, AVG(trust) FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id = T2.target_u_id GROUP BY T2.target_u_id
Find the name of the target user with the lowest trust score.
Additional table information: table: epinions_1
SQL: SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id = T2.target_u_id ORDER BY trust NULLS FIRST LIMIT 1
Find the names of the items that did not receive any review.
Additional table information: table: epinions_1
SQL: SELECT title FROM item WHERE NOT i_id IN (SELECT i_id FROM review)
Find the number of users who did not write any review.
Additional table information: table: epinions_1
SQL: SELECT COUNT(*) FROM useracct WHERE NOT u_id IN (SELECT u_id FROM review)
Find the number of items without any review.
Additional table information: table: epinions_1
SQL: SELECT COUNT(*) FROM item WHERE NOT i_id IN (SELECT i_id FROM review)
How many players are there?
Additional table information: table: riding_club
SQL: SELECT COUNT(*) FROM player
List the names of players in ascending order of votes.
Additional table information: table: riding_club
SQL: SELECT Player_name FROM player ORDER BY Votes ASC NULLS FIRST
What are the gender and occupation of players?
Additional table information: table: riding_club
SQL: SELECT Gender, Occupation FROM player
List the name and residence for players whose occupation is not 'Researcher'.
Additional table information: table: riding_club
SQL: SELECT Player_name, residence FROM player WHERE Occupation <> 'Researcher'
Show the names of sponsors of players whose residence is either 'Brandon' or 'Birtle'.
Additional table information: table: riding_club
SQL: SELECT Sponsor_name FROM player WHERE Residence = 'Brandon' OR Residence = 'Birtle'
What is the name of the player with the largest number of votes?
Additional table information: table: riding_club
SQL: SELECT Player_name FROM player ORDER BY Votes DESC LIMIT 1
Show different occupations along with the number of players in each occupation.
Additional table information: table: riding_club
SQL: SELECT Occupation, COUNT(*) FROM player GROUP BY Occupation
Please show the most common occupation of players.
Additional table information: table: riding_club
SQL: SELECT Occupation FROM player GROUP BY Occupation ORDER BY COUNT(*) DESC LIMIT 1
Show the residences that have at least two players.
Additional table information: table: riding_club
SQL: SELECT Residence FROM player GROUP BY Residence HAVING COUNT(*) >= 2
Show the names of players and names of their coaches.
Additional table information: table: riding_club
SQL: SELECT T3.Player_name, T2.coach_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID
Show the names of players coached by the rank 1 coach.
Additional table information: table: riding_club
SQL: SELECT T3.Player_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID WHERE T2.Rank = 1
Show the names and genders of players with a coach starting after 2011.
Additional table information: table: riding_club
SQL: SELECT T3.Player_name, T3.gender FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID WHERE T1.Starting_year > 2011
Show the names of players and names of their coaches in descending order of the votes of players.
Additional table information: table: riding_club
SQL: SELECT T3.Player_name, T2.coach_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID ORDER BY T3.Votes DESC