prompt
stringlengths
81
567
completion
stringlengths
18
557
Question: What is the average, minimum, maximum, and total transaction amount? Context: CREATE TABLE Financial_transactions (transaction_amount INTEGER) Answer:
SELECT AVG(transaction_amount), MIN(transaction_amount), MAX(transaction_amount), SUM(transaction_amount) FROM Financial_transactions
Question: Show ids for all transactions whose amounts are greater than the average. Context: CREATE TABLE Financial_transactions (transaction_id VARCHAR, transaction_amount INTEGER) Answer:
SELECT transaction_id FROM Financial_transactions WHERE transaction_amount > (SELECT AVG(transaction_amount) FROM Financial_transactions)
Question: Show the transaction types and the total amount of transactions. Context: CREATE TABLE Financial_transactions (transaction_type VARCHAR, transaction_amount INTEGER) Answer:
SELECT transaction_type, SUM(transaction_amount) FROM Financial_transactions GROUP BY transaction_type
Question: Show the account name, id and the number of transactions for each account. Context: CREATE TABLE Financial_transactions (account_id VARCHAR); CREATE TABLE Accounts (account_name VARCHAR, account_id VARCHAR) Answer:
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
Question: Show the account id with most number of transactions. Context: CREATE TABLE Financial_transactions (account_id VARCHAR) Answer:
SELECT account_id FROM Financial_transactions GROUP BY account_id ORDER BY COUNT(*) DESC LIMIT 1
Question: Show the account id and name with at least 4 transactions. Context: CREATE TABLE Financial_transactions (account_id VARCHAR); CREATE TABLE Accounts (account_name VARCHAR, account_id VARCHAR) Answer:
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
Question: Show all product sizes. Context: CREATE TABLE Products (product_size VARCHAR) Answer:
SELECT DISTINCT product_size FROM Products
Question: Show all product colors. Context: CREATE TABLE Products (product_color VARCHAR) Answer:
SELECT DISTINCT product_color FROM Products
Question: Show the invoice number and the number of transactions for each invoice. Context: CREATE TABLE Financial_transactions (invoice_number VARCHAR) Answer:
SELECT invoice_number, COUNT(*) FROM Financial_transactions GROUP BY invoice_number
Question: What is the invoice number and invoice date for the invoice with most number of transactions? Context: CREATE TABLE Invoices (invoice_number VARCHAR, invoice_date VARCHAR); CREATE TABLE Financial_transactions (invoice_number VARCHAR) Answer:
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
Question: How many invoices do we have? Context: CREATE TABLE Invoices (Id VARCHAR) Answer:
SELECT COUNT(*) FROM Invoices
Question: Show invoice dates and order id and details for all invoices. Context: CREATE TABLE Invoices (invoice_date VARCHAR, order_id VARCHAR); CREATE TABLE Orders (order_details VARCHAR, order_id VARCHAR) Answer:
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
Question: Show the order ids and the number of invoices for each order. Context: CREATE TABLE Invoices (order_id VARCHAR) Answer:
SELECT order_id, COUNT(*) FROM Invoices GROUP BY order_id
Question: What is the order id and order details for the order more than two invoices. Context: CREATE TABLE Orders (order_id VARCHAR, order_details VARCHAR); CREATE TABLE Invoices (order_id VARCHAR) Answer:
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
Question: What is the customer last name, id and phone number with most number of orders? Context: CREATE TABLE Orders (customer_id VARCHAR); CREATE TABLE Customers (customer_last_name VARCHAR, phone_number VARCHAR, customer_id VARCHAR) Answer:
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
Question: Show all product names without an order. Context: CREATE TABLE Products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE Order_items (product_id VARCHAR); CREATE TABLE Products (product_name VARCHAR) Answer:
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
Question: Show all product names and the total quantity ordered for each product name. Context: CREATE TABLE Products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE Order_items (product_quantity INTEGER, product_id VARCHAR) Answer:
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
Question: Show the order ids and the number of items in each order. Context: CREATE TABLE Order_items (order_id VARCHAR) Answer:
SELECT order_id, COUNT(*) FROM Order_items GROUP BY order_id
Question: Show the product ids and the number of unique orders containing each product. Context: CREATE TABLE Order_items (product_id VARCHAR, order_id VARCHAR) Answer:
SELECT product_id, COUNT(DISTINCT order_id) FROM Order_items GROUP BY product_id
Question: Show all product names and the number of customers having an order on each product. Context: CREATE TABLE Order_items (product_id VARCHAR, order_id VARCHAR); CREATE TABLE Orders (order_id VARCHAR); CREATE TABLE Products (product_name VARCHAR, product_id VARCHAR) Answer:
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
Question: Show order ids and the number of products in each order. Context: CREATE TABLE Order_items (order_id VARCHAR, product_id VARCHAR) Answer:
SELECT order_id, COUNT(DISTINCT product_id) FROM Order_items GROUP BY order_id
Question: Show order ids and the total quantity in each order. Context: CREATE TABLE Order_items (order_id VARCHAR, product_quantity INTEGER) Answer:
SELECT order_id, SUM(product_quantity) FROM Order_items GROUP BY order_id
Question: How many products were not included in any order? Context: CREATE TABLE products (product_id VARCHAR); CREATE TABLE Order_items (product_id VARCHAR) Answer:
SELECT COUNT(*) FROM products WHERE NOT product_id IN (SELECT product_id FROM Order_items)
Question: How many churches opened before 1850 are there? Context: CREATE TABLE Church (Open_Date INTEGER) Answer:
SELECT COUNT(*) FROM Church WHERE Open_Date < 1850
Question: Show the name, open date, and organizer for all churches. Context: CREATE TABLE Church (name VARCHAR, open_date VARCHAR, organized_by VARCHAR) Answer:
SELECT name, open_date, organized_by FROM Church
Question: List all church names in descending order of opening date. Context: CREATE TABLE church (name VARCHAR, open_date VARCHAR) Answer:
SELECT name FROM church ORDER BY open_date DESC
Question: Show the opening year in whcih at least two churches opened. Context: CREATE TABLE church (open_date VARCHAR) Answer:
SELECT open_date FROM church GROUP BY open_date HAVING COUNT(*) >= 2
Question: Show the organizer and name for churches that opened between 1830 and 1840. Context: CREATE TABLE church (organized_by VARCHAR, name VARCHAR, open_date INTEGER) Answer:
SELECT organized_by, name FROM church WHERE open_date BETWEEN 1830 AND 1840
Question: Show all opening years and the number of churches that opened in that year. Context: CREATE TABLE church (open_date VARCHAR) Answer:
SELECT open_date, COUNT(*) FROM church GROUP BY open_date
Question: Show the name and opening year for three churches that opened most recently. Context: CREATE TABLE church (name VARCHAR, open_date VARCHAR) Answer:
SELECT name, open_date FROM church ORDER BY open_date DESC LIMIT 3
Question: How many female people are older than 30 in our record? Context: CREATE TABLE people (is_male VARCHAR, age VARCHAR) Answer:
SELECT COUNT(*) FROM people WHERE is_male = 'F' AND age > 30
Question: Show the country where people older than 30 and younger than 25 are from. Context: CREATE TABLE people (country VARCHAR, age INTEGER) Answer:
SELECT country FROM people WHERE age < 25 INTERSECT SELECT country FROM people WHERE age > 30
Question: Show the minimum, maximum, and average age for all people. Context: CREATE TABLE people (age INTEGER) Answer:
SELECT MIN(age), MAX(age), AVG(age) FROM people
Question: Show the name and country for all people whose age is smaller than the average. Context: CREATE TABLE people (name VARCHAR, country VARCHAR, age INTEGER) Answer:
SELECT name, country FROM people WHERE age < (SELECT AVG(age) FROM people)
Question: Show the pair of male and female names in all weddings after year 2014 Context: CREATE TABLE wedding (male_id VARCHAR, female_id VARCHAR, year INTEGER); CREATE TABLE people (name VARCHAR, people_id VARCHAR) Answer:
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
Question: Show the name and age for all male people who don't have a wedding. Context: CREATE TABLE wedding (name VARCHAR, age VARCHAR, is_male VARCHAR, people_id VARCHAR, male_id VARCHAR); CREATE TABLE people (name VARCHAR, age VARCHAR, is_male VARCHAR, people_id VARCHAR, male_id VARCHAR) Answer:
SELECT name, age FROM people WHERE is_male = 'T' AND NOT people_id IN (SELECT male_id FROM wedding)
Question: Show all church names except for those that had a wedding in year 2015. Context: CREATE TABLE church (name VARCHAR); CREATE TABLE wedding (church_id VARCHAR, year VARCHAR); CREATE TABLE church (name VARCHAR, church_id VARCHAR) Answer:
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
Question: Show all church names that have hosted least two weddings. Context: CREATE TABLE wedding (church_id VARCHAR); CREATE TABLE church (name VARCHAR, church_id VARCHAR) Answer:
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
Question: Show the names for all females from Canada having a wedding in year 2016. Context: CREATE TABLE people (name VARCHAR, people_id VARCHAR, country VARCHAR, is_male VARCHAR); CREATE TABLE wedding (female_id VARCHAR, year VARCHAR) Answer:
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'
Question: How many weddings are there in year 2016? Context: CREATE TABLE wedding (YEAR VARCHAR) Answer:
SELECT COUNT(*) FROM wedding WHERE YEAR = 2016
Question: Show the church names for the weddings of all people older than 30. Context: CREATE TABLE church (name VARCHAR, church_id VARCHAR); CREATE TABLE people (people_id VARCHAR, age VARCHAR); CREATE TABLE wedding (male_id VARCHAR, female_id VARCHAR, church_id VARCHAR) Answer:
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
Question: Show all countries and the number of people from each country. Context: CREATE TABLE people (country VARCHAR) Answer:
SELECT country, COUNT(*) FROM people GROUP BY country
Question: How many churches have a wedding in year 2016? Context: CREATE TABLE wedding (church_id VARCHAR, YEAR VARCHAR) Answer:
SELECT COUNT(DISTINCT church_id) FROM wedding WHERE YEAR = 2016
Question: How many artists do we have? Context: CREATE TABLE artist (Id VARCHAR) Answer:
SELECT COUNT(*) FROM artist
Question: Show all artist name, age, and country ordered by the yeared they joined. Context: CREATE TABLE artist (name VARCHAR, age VARCHAR, country VARCHAR, Year_Join VARCHAR) Answer:
SELECT name, age, country FROM artist ORDER BY Year_Join
Question: What are all distinct country for artists? Context: CREATE TABLE artist (country VARCHAR) Answer:
SELECT DISTINCT country FROM artist
Question: Show all artist names and the year joined who are not from United States. Context: CREATE TABLE artist (name VARCHAR, year_join VARCHAR, country VARCHAR) Answer:
SELECT name, year_join FROM artist WHERE country <> 'United States'
Question: How many artists are above age 46 and joined after 1990? Context: CREATE TABLE artist (age VARCHAR, year_join VARCHAR) Answer:
SELECT COUNT(*) FROM artist WHERE age > 46 AND year_join > 1990
Question: What is the average and minimum age of all artists from United States. Context: CREATE TABLE artist (age INTEGER, country VARCHAR) Answer:
SELECT AVG(age), MIN(age) FROM artist WHERE country = 'United States'
Question: What is the name of the artist who joined latest? Context: CREATE TABLE artist (name VARCHAR, year_join VARCHAR) Answer:
SELECT name FROM artist ORDER BY year_join DESC LIMIT 1
Question: How many exhibition are there in year 2005 or after? Context: CREATE TABLE exhibition (YEAR VARCHAR) Answer:
SELECT COUNT(*) FROM exhibition WHERE YEAR >= 2005
Question: Show theme and year for all exhibitions with ticket prices lower than 15. Context: CREATE TABLE exhibition (theme VARCHAR, YEAR VARCHAR, ticket_price INTEGER) Answer:
SELECT theme, YEAR FROM exhibition WHERE ticket_price < 15
Question: Show all artist names and the number of exhibitions for each artist. Context: CREATE TABLE artist (name VARCHAR, artist_id VARCHAR); CREATE TABLE exhibition (artist_id VARCHAR) Answer:
SELECT T2.name, COUNT(*) FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id
Question: What is the name and country for the artist with most number of exhibitions? Context: CREATE TABLE exhibition (artist_id VARCHAR); CREATE TABLE artist (name VARCHAR, country VARCHAR, artist_id VARCHAR) Answer:
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
Question: Show names for artists without any exhibition. Context: CREATE TABLE artist (name VARCHAR, artist_id VARCHAR); CREATE TABLE exhibition (name VARCHAR, artist_id VARCHAR) Answer:
SELECT name FROM artist WHERE NOT artist_id IN (SELECT artist_id FROM exhibition)
Question: What is the theme and artist name for the exhibition with a ticket price higher than the average? Context: CREATE TABLE exhibition (ticket_price INTEGER); CREATE TABLE exhibition (theme VARCHAR, artist_id VARCHAR, ticket_price INTEGER); CREATE TABLE artist (name VARCHAR, artist_id VARCHAR) Answer:
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)
Question: Show the average, minimum, and maximum ticket prices for exhibitions for all years before 2009. Context: CREATE TABLE exhibition (ticket_price INTEGER, YEAR INTEGER) Answer:
SELECT AVG(ticket_price), MIN(ticket_price), MAX(ticket_price) FROM exhibition WHERE YEAR < 2009
Question: Show theme and year for all exhibitions in an descending order of ticket price. Context: CREATE TABLE exhibition (theme VARCHAR, YEAR VARCHAR, ticket_price VARCHAR) Answer:
SELECT theme, YEAR FROM exhibition ORDER BY ticket_price DESC
Question: What is the theme, date, and attendance for the exhibition in year 2004? Context: CREATE TABLE exhibition_record (date VARCHAR, attendance VARCHAR, exhibition_id VARCHAR); CREATE TABLE exhibition (theme VARCHAR, exhibition_id VARCHAR, year VARCHAR) Answer:
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
Question: Show all artist names who didn't have an exhibition in 2004. Context: CREATE TABLE exhibition (artist_id VARCHAR, year VARCHAR); CREATE TABLE artist (name VARCHAR); CREATE TABLE artist (name VARCHAR, artist_id VARCHAR) Answer:
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
Question: Show the theme for exhibitions with both records of an attendance below 100 and above 500. Context: CREATE TABLE exhibition (theme VARCHAR, exhibition_id VARCHAR); CREATE TABLE exhibition_record (exhibition_id VARCHAR, attendance INTEGER) Answer:
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
Question: How many exhibitions have a attendance more than 100 or have a ticket price below 10? Context: CREATE TABLE exhibition_record (exhibition_id VARCHAR, attendance VARCHAR); CREATE TABLE exhibition (exhibition_id VARCHAR, ticket_price VARCHAR) Answer:
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
Question: Show all artist names with an average exhibition attendance over 200. Context: CREATE TABLE artist (name VARCHAR, artist_id VARCHAR); CREATE TABLE exhibition (exhibition_id VARCHAR, artist_id VARCHAR); CREATE TABLE exhibition_record (exhibition_id VARCHAR, attendance INTEGER) Answer:
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
Question: Find the id of the item whose title is "orange". Context: CREATE TABLE item (i_id VARCHAR, title VARCHAR) Answer:
SELECT i_id FROM item WHERE title = "orange"
Question: List all information in the item table. Context: CREATE TABLE item (Id VARCHAR) Answer:
SELECT * FROM item
Question: Find the number of reviews. Context: CREATE TABLE review (Id VARCHAR) Answer:
SELECT COUNT(*) FROM review
Question: How many users are there? Context: CREATE TABLE useracct (Id VARCHAR) Answer:
SELECT COUNT(*) FROM useracct
Question: Find the average and maximum rating of all reviews. Context: CREATE TABLE review (rating INTEGER) Answer:
SELECT AVG(rating), MAX(rating) FROM review
Question: Find the highest rank of all reviews. Context: CREATE TABLE review (rank INTEGER) Answer:
SELECT MIN(rank) FROM review
Question: How many different users wrote some reviews? Context: CREATE TABLE review (u_id VARCHAR) Answer:
SELECT COUNT(DISTINCT u_id) FROM review
Question: How many different items were reviewed by some users? Context: CREATE TABLE review (i_id VARCHAR) Answer:
SELECT COUNT(DISTINCT i_id) FROM review
Question: Find the number of items that did not receive any review. Context: CREATE TABLE review (i_id VARCHAR); CREATE TABLE item (i_id VARCHAR) Answer:
SELECT COUNT(*) FROM item WHERE NOT i_id IN (SELECT i_id FROM review)
Question: Find the names of users who did not leave any review. Context: CREATE TABLE review (name VARCHAR, u_id VARCHAR); CREATE TABLE useracct (name VARCHAR, u_id VARCHAR) Answer:
SELECT name FROM useracct WHERE NOT u_id IN (SELECT u_id FROM review)
Question: Find the names of goods that receive a rating of 10. Context: CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (i_id VARCHAR, rating VARCHAR) Answer:
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating = 10
Question: Find the titles of items whose rating is higher than the average review rating of all items. Context: CREATE TABLE review (rating INTEGER); CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (i_id VARCHAR, rating INTEGER) Answer:
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)
Question: Find the titles of items that received any rating below 5. Context: CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (i_id VARCHAR, rating INTEGER) Answer:
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating < 5
Question: Find the titles of items that received both a rating higher than 8 and a rating below 5. Context: CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (i_id VARCHAR, rating INTEGER) Answer:
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
Question: Find the names of items whose rank is higher than 3 and whose average rating is above 5. Context: CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (i_id VARCHAR, rank INTEGER, rating INTEGER) Answer:
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
Question: Find the name of the item with the lowest average rating. Context: CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (i_id VARCHAR, rating INTEGER) Answer:
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) LIMIT 1
Question: List the titles of all items in alphabetic order . Context: CREATE TABLE item (title VARCHAR) Answer:
SELECT title FROM item ORDER BY title
Question: Find the name of the user who gives the most reviews. Context: CREATE TABLE useracct (name VARCHAR, u_id VARCHAR); CREATE TABLE review (u_id VARCHAR) Answer:
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
Question: Find the name and id of the item with the highest average rating. Context: CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (i_id VARCHAR, rating INTEGER) Answer:
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
Question: Find the name and id of the good with the highest average rank. Context: CREATE TABLE review (i_id VARCHAR, rank INTEGER); CREATE TABLE item (title VARCHAR, i_id VARCHAR) Answer:
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
Question: For each user, return the name and the average rating of reviews given by them. Context: CREATE TABLE review (rating INTEGER, u_id VARCHAR); CREATE TABLE useracct (name VARCHAR, u_id VARCHAR) Answer:
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
Question: For each user, find their name and the number of reviews written by them. Context: CREATE TABLE useracct (name VARCHAR, u_id VARCHAR); CREATE TABLE review (u_id VARCHAR) Answer:
SELECT T1.name, COUNT(*) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id GROUP BY T2.u_id
Question: Find the name of the user who gave the highest rating. Context: CREATE TABLE review (u_id VARCHAR, rating VARCHAR); CREATE TABLE useracct (name VARCHAR, u_id VARCHAR) Answer:
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
Question: Find the name of the source user with the highest average trust score. Context: CREATE TABLE useracct (name VARCHAR, u_id VARCHAR); CREATE TABLE trust (source_u_id VARCHAR) Answer:
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
Question: Find each target user's name and average trust score. Context: CREATE TABLE trust (target_u_id VARCHAR); CREATE TABLE useracct (name VARCHAR, u_id VARCHAR) Answer:
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
Question: Find the name of the target user with the lowest trust score. Context: CREATE TABLE trust (target_u_id VARCHAR); CREATE TABLE useracct (name VARCHAR, u_id VARCHAR) Answer:
SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id = T2.target_u_id ORDER BY trust LIMIT 1
Question: Find the names of the items that did not receive any review. Context: CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (title VARCHAR, i_id VARCHAR) Answer:
SELECT title FROM item WHERE NOT i_id IN (SELECT i_id FROM review)
Question: Find the number of users who did not write any review. Context: CREATE TABLE review (u_id VARCHAR); CREATE TABLE useracct (u_id VARCHAR) Answer:
SELECT COUNT(*) FROM useracct WHERE NOT u_id IN (SELECT u_id FROM review)
Question: How many players are there? Context: CREATE TABLE player (Id VARCHAR) Answer:
SELECT COUNT(*) FROM player
Question: List the names of players in ascending order of votes. Context: CREATE TABLE player (Player_name VARCHAR, Votes VARCHAR) Answer:
SELECT Player_name FROM player ORDER BY Votes
Question: What are the gender and occupation of players? Context: CREATE TABLE player (Gender VARCHAR, Occupation VARCHAR) Answer:
SELECT Gender, Occupation FROM player
Question: List the name and residence for players whose occupation is not "Researcher". Context: CREATE TABLE player (Player_name VARCHAR, residence VARCHAR, Occupation VARCHAR) Answer:
SELECT Player_name, residence FROM player WHERE Occupation <> "Researcher"
Question: Show the names of sponsors of players whose residence is either "Brandon" or "Birtle". Context: CREATE TABLE player (Sponsor_name VARCHAR, Residence VARCHAR) Answer:
SELECT Sponsor_name FROM player WHERE Residence = "Brandon" OR Residence = "Birtle"
Question: What is the name of the player with the largest number of votes? Context: CREATE TABLE player (Player_name VARCHAR, Votes VARCHAR) Answer:
SELECT Player_name FROM player ORDER BY Votes DESC LIMIT 1
Question: Show different occupations along with the number of players in each occupation. Context: CREATE TABLE player (Occupation VARCHAR) Answer:
SELECT Occupation, COUNT(*) FROM player GROUP BY Occupation
Question: Please show the most common occupation of players. Context: CREATE TABLE player (Occupation VARCHAR) Answer:
SELECT Occupation FROM player GROUP BY Occupation ORDER BY COUNT(*) DESC LIMIT 1
Question: Show the residences that have at least two players. Context: CREATE TABLE player (Residence VARCHAR) Answer:
SELECT Residence FROM player GROUP BY Residence HAVING COUNT(*) >= 2