database_id
stringlengths
4
31
query
stringlengths
22
577
question
stringlengths
19
224
movie_1
SELECT title FROM Movie WHERE director = 'James Cameron' AND YEAR > 2000
What is the name of the movie produced after 2000 and directed by James Cameron?
movie_1
SELECT rID FROM Reviewer WHERE name LIKE "%Mike%"
What is the id of the reviewer whose name has substring “Mike”?
movie_1
SELECT max(stars) , min(stars) FROM Rating
What is the lowest and highest rating star?
movie_1
SELECT DISTINCT YEAR FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars >= 4 ORDER BY T1.year
Find all years that have a movie that received a rating of 4 or 5, and sort them in increasing order of year.
movie_1
SELECT T1.director , T1.title FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars = 5
What are the names of directors who directed movies with 5 star rating? Also return the title of these movies.
movie_1
SELECT T2.name , avg(T1.stars) FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID GROUP BY T2.name
What is the average rating star for each reviewer?
movie_1
SELECT title FROM Movie WHERE mID NOT IN (SELECT mID FROM Rating)
Find the titles of all movies that have no ratings.
movie_1
SELECT avg(T1.stars) , T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.year = (SELECT min(YEAR) FROM Movie)
What is the average rating stars and title for the oldest movie?
movie_1
SELECT title FROM Movie WHERE YEAR = (SELECT max(YEAR) FROM Movie)
What is the name of the most recent movie?
movie_1
SELECT max(T1.stars) , T2.year FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.year = (SELECT max(YEAR) FROM Movie)
What is the maximum stars and year for the most recent movie?
movie_1
SELECT title FROM Movie WHERE YEAR > (SELECT max(YEAR) FROM Movie WHERE director = "Steven Spielberg")
What are the names of movies whose created year is after all movies directed by Steven Spielberg?
movie_1
SELECT T2.title , T2.director FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars > (SELECT avg(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.director = "James Cameron")
What are the titles and directors of the movies whose star is greater than the average stars of the movies directed by James Cameron?
movie_1
SELECT T3.name , T2.title , T1.stars , T1.ratingDate FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID ORDER BY T3.name , T2.title , T1.stars
Return reviewer name, movie title, stars, and rating date. And sort the data first by reviewer name, then by movie title, and lastly by number of stars.
movie_1
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID GROUP BY T1.rID HAVING COUNT(*) >= 3
Find the names of all reviewers who have contributed three or more ratings.
movie_1
SELECT DISTINCT T3.name FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T2.title = 'Gone with the Wind'
Find the names of all reviewers who rated Gone with the Wind.
movie_1
SELECT DISTINCT T2.director FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T3.name = 'Sarah Martinez'
Find the names of all directors whose movies are rated by Sarah Martinez.
movie_1
SELECT DISTINCT T3.name , T2.title , T1.stars FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T2.director = T3.name
For any rating where the name of reviewer is the same as the director of the movie, return the reviewer name, movie title, and number of stars.
movie_1
SELECT name FROM Reviewer UNION SELECT title FROM Movie
Return all reviewer names and movie names together in a single list.
movie_1
SELECT DISTINCT title FROM Movie EXCEPT SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T3.name = 'Chris Jackson'
Find the titles of all movies not reviewed by Chris Jackson.
movie_1
SELECT T1.title , T1.director FROM Movie AS T1 JOIN Movie AS T2 ON T1.director = T2.director WHERE T1.title != T2.title ORDER BY T1.director , T1.title
For all directors who directed more than one movie, return the titles of all movies directed by them, along with the director name. Sort by director name, then movie title.
movie_1
SELECT T1.title , T1.year FROM Movie AS T1 JOIN Movie AS T2 ON T1.director = T2.director WHERE T1.title != T2.title
For directors who had more than one movie, return the titles and produced years of all movies directed by them.
movie_1
SELECT director FROM Movie GROUP BY director HAVING count(*) = 1
What are the names of the directors who made exactly one movie?
movie_1
SELECT director FROM Movie WHERE director != "null" GROUP BY director HAVING count(*) = 1
What are the names of the directors who made exactly one movie excluding director NULL?
movie_1
SELECT count(*) , T1.director FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID GROUP BY T1.director
How many movie reviews does each director get?
movie_1
SELECT T2.title , avg(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T1.mID ORDER BY avg(T1.stars) DESC LIMIT 1
Find the movies with the highest average rating. Return the movie titles and average rating.
movie_1
SELECT T2.title , avg(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T1.mID ORDER BY avg(T1.stars) LIMIT 1
What are the movie titles and average rating of the movies with the lowest average rating?
movie_1
SELECT T2.title , T2.year FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID ORDER BY T1.stars DESC LIMIT 3
What are the names and years of the movies that has the top 3 highest rating star?
movie_1
SELECT T2.title , T2.director , max(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE director != "null" GROUP BY director
For each director, return the director's name together with the title of the movie they directed that received the highest rating among all of their movies, and the value of that rating. Ignore movies whose director is NULL.
movie_1
SELECT T2.title , T1.rID , T1.stars , min(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T1.rID
Find the title and star rating of the movie that got the least rating star for each reviewer.
movie_1
SELECT T2.title , T1.stars , T2.director , min(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T2.director
Find the title and score of the movie with the lowest rating among all movies directed by each director.
movie_1
SELECT T2.title , T1.mID FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T1.mID ORDER BY count(*) DESC LIMIT 1
What is the name of the movie that is rated by most of times?
movie_1
SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars BETWEEN 3 AND 5
What are the titles of all movies that have rating star is between 3 and 5?
movie_1
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars > 3
Find the names of reviewers who had given higher than 3 stars ratings.
movie_1
SELECT mID , avg(stars) FROM Rating WHERE mID NOT IN (SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T2.name = "Brittany Harris") GROUP BY mID
Find the average rating star for each movie that are not reviewed by Brittany Harris.
movie_1
SELECT mID FROM Rating EXCEPT SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T2.name = "Brittany Harris"
What are the ids of the movies that are not reviewed by Brittany Harris.
movie_1
SELECT mID , avg(stars) FROM Rating GROUP BY mID HAVING count(*) >= 2
Find the average rating star for each movie that received at least 2 ratings.
movie_1
SELECT rID FROM Rating EXCEPT SELECT rID FROM Rating WHERE stars = 4
find the ids of reviewers who did not give 4 star.
movie_1
SELECT DISTINCT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T3.name = 'Brittany Harris' OR T2.year > 2000
What are names of the movies that are either made after 2000 or reviewed by Brittany Harris?
movie_1
SELECT title FROM Movie WHERE director = "James Cameron" OR YEAR < 1980
What are names of the movies that are either made before 1980 or directed by James Cameron?
movie_1
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars = 3 INTERSECT SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars = 4
What are the names of reviewers who had rated 3 star and 4 star?
epinions_1
SELECT avg(rating) , max(rating) FROM review
Find the average and maximum rating of all reviews.
epinions_1
SELECT count(*) FROM item WHERE i_id NOT IN (SELECT i_id FROM review)
Find the number of items that did not receive any review.
epinions_1
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating = 10
Find the names of goods that receive a rating of 10.
epinions_1
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 whose rating is higher than the average review rating of all items.
epinions_1
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 any rating below 5.
epinions_1
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 titles of items that received both a rating higher than 8 and a rating below 5.
epinions_1
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 names of items whose rank is higher than 3 and whose average rating is above 5.
epinions_1
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
Find the name of the item with the lowest average rating.
epinions_1
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 of the user who gives the most reviews.
epinions_1
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 item with the highest average rating.
epinions_1
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
Find the name and id of the good with the highest average rank.
epinions_1
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, return the name and the average rating of reviews given by them.
epinions_1
SELECT T1.name , count(*) 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.
epinions_1
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 user who gave the highest rating.
epinions_1
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 the name of the source user with the highest average trust score.
epinions_1
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 each target user's name and average trust score.
epinions_1
SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id = T2.target_u_id ORDER BY trust LIMIT 1
Find the name of the target user with the lowest trust score.
epinions_1
SELECT title FROM item WHERE i_id NOT IN (SELECT i_id FROM review)
Find the names of the items that did not receive any review.
epinions_1
SELECT name FROM useracct WHERE u_id NOT IN (SELECT u_id FROM review)
Find the names of users who did not leave any review.
customer_complaints
SELECT town_city FROM customers WHERE customer_type_code = "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1
Which city has the least number of customers whose type code is "Good Credit Rating"?
customer_complaints
SELECT t1.product_name , count(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_name
List the name of all products along with the number of complaints that they have received.
customer_complaints
SELECT t1.email_address FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY count(*) DESC LIMIT 1
Find the email of the customer who has filed the most complaints.
customer_complaints
SELECT DISTINCT t1.product_name FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id JOIN customers AS t3 GROUP BY t3.customer_id ORDER BY count(*) LIMIT 1
Which products has been complained by the customer who has filed least amount of complaints?
customer_complaints
SELECT t1.phone_number FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id ORDER BY t2.date_complaint_raised DESC LIMIT 1
What is the phone number of the customer who has filed the most recent complaint?
customer_complaints
SELECT email_address , phone_number FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM complaints)
Find the email and phone number of the customers who have never filed a complaint before.
customer_complaints
SELECT phone_number FROM customers UNION SELECT phone_number FROM staff
Find the phone number of all the customers and staff.
customer_complaints
SELECT product_name , product_category_code FROM products ORDER BY product_price DESC LIMIT 1
Find the name and category of the most expensive product.
customer_complaints
SELECT product_price FROM products WHERE product_id NOT IN (SELECT product_id FROM complaints)
Find the prices of products which has never received a single complaint.
customer_complaints
SELECT last_name from staff where staff_id in (SELECT staff_id from complaints WHERE product_id in (SELECT product_id FROM products ORDER BY product_price ASC LIMIT 1))
Find the last names of the staff members who processed complaints about the cheapest product.
customer_complaints
SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING count(*) > 3
Which complaint status has more than 3 records on file?
customer_complaints
SELECT last_name FROM staff WHERE email_address LIKE "%wrau%"
Find the last name of the staff whose email address contains "wrau".
customer_complaints
SELECT count(*) FROM customers GROUP BY customer_type_code ORDER BY count(*) DESC LIMIT 1
How many customers are there in the customer type with the most customers?
customer_complaints
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id ORDER BY t2.date_complaint_raised LIMIT 1
What is the last name of the staff who has handled the first ever complaint?
customer_complaints
SELECT complaint_status_code , count(*) FROM complaints WHERE complaint_type_code = "Product Failure" GROUP BY complaint_status_code
Find the number of complaints with Product Failure type for each complaint status.
customer_complaints
SELECT t1.first_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id GROUP BY t2.staff_id ORDER BY count(*) LIMIT 5
What are the first names of the top 5 staff who have handled the greatest number of complaints?
restaurant_1
SELECT ResName , Rating FROM Restaurant ORDER BY Rating DESC LIMIT 1;
Which restaurant has highest rating? List the restaurant name and its rating.
restaurant_1
SELECT Age FROM Student WHERE Fname = "Linda" AND Lname = "Smith";
What is the age of student Linda Smith?
restaurant_1
SELECT Sex FROM Student WHERE Fname = "Linda" AND Lname = "Smith";
What is the gender of the student Linda Smith?
restaurant_1
SELECT city_code FROM Student WHERE Fname = "Linda" AND Lname = "Smith";
Which city does student Linda Smith live in?
restaurant_1
SELECT Advisor , count(*) FROM Student GROUP BY Advisor ORDER BY count(Advisor) DESC LIMIT 1;
Which Advisor has most of students? List advisor and the number of students.
restaurant_1
SELECT Major , count(*) FROM Student GROUP BY Major ORDER BY count(Major) ASC LIMIT 1;
Which major has least number of students? List the major and the number of students.
restaurant_1
SELECT Major , count(*) FROM Student GROUP BY Major HAVING count(Major) BETWEEN 2 AND 30;
Which major has between 2 and 30 number of students? List major and the number of students.
restaurant_1
SELECT Fname , Lname FROM Student WHERE Age > 18 AND Major = 600;
Which student's age is older than 18 and is majoring in 600? List each student's first and last name.
restaurant_1
SELECT Fname , Lname FROM Student WHERE Age > 18 AND Major != 600 AND Sex = 'F';
List all female students older than 18 who are not majoring in 600. List students' first name and last name.
restaurant_1
SELECT count(*) FROM Restaurant JOIN Type_Of_Restaurant ON Restaurant.ResID = Type_Of_Restaurant.ResID JOIN Restaurant_Type ON Type_Of_Restaurant.ResTypeID = Restaurant_Type.ResTypeID GROUP BY Type_Of_Restaurant.ResTypeID HAVING Restaurant_Type.ResTypeName = 'Sandwich'
How many restaurant is the Sandwich type restaurant?
restaurant_1
SELECT sum(Spent) FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID WHERE Student.Fname = "Linda" AND Student.Lname = "Smith";
How long does student Linda Smith spend on the restaurant in total?
restaurant_1
SELECT count(*) FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID JOIN Restaurant ON Visits_Restaurant.ResID = Restaurant.ResID WHERE Student.Fname = "Linda" AND Student.Lname = "Smith" AND Restaurant.ResName = "Subway";
How many times has the student Linda Smith visited Subway?
restaurant_1
SELECT TIME FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID JOIN Restaurant ON Visits_Restaurant.ResID = Restaurant.ResID WHERE Student.Fname = "Linda" AND Student.Lname = "Smith" AND Restaurant.ResName = "Subway";
When did Linda Smith visit Subway?
restaurant_1
SELECT Restaurant.ResName , sum(Visits_Restaurant.Spent) FROM Visits_Restaurant JOIN Restaurant ON Visits_Restaurant.ResID = Restaurant.ResID GROUP BY Restaurant.ResID ORDER BY sum(Visits_Restaurant.Spent) ASC LIMIT 1;
At which restaurant did the students spend the least amount of time? List restaurant and the time students spent on in total.
insurance_and_eClaims
SELECT policy_type_code FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t2.customer_details = "Dayana Robel"
Find all the policy type codes associated with the customer "Dayana Robel"
insurance_and_eClaims
SELECT policy_type_code FROM policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1
Which type of policy is most frequently used? Give me the policy type code.
insurance_and_eClaims
SELECT policy_type_code FROM policies GROUP BY policy_type_code HAVING count(*) > 2
Find all the policy types that are used by more than 2 customers.
insurance_and_eClaims
SELECT sum(amount_piad) , avg(amount_piad) FROM claim_headers
Find the total and average amount paid in claim headers.
insurance_and_eClaims
SELECT sum(t1.amount_claimed) FROM claim_headers AS t1 JOIN claims_documents AS t2 ON t1.claim_header_id = t2.claim_id WHERE t2.created_date = (SELECT created_date FROM claims_documents ORDER BY created_date LIMIT 1)
Find the total amount claimed in the most recently created document.
insurance_and_eClaims
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 largest amount of claim in a single claim?
insurance_and_eClaims
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)
What is the name of the customer who has made the minimum amount of payment in one claim?
insurance_and_eClaims
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
Find the names of customers who have no policies associated.
insurance_and_eClaims
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
What is the name of the claim processing stage that most of the claims are on?
insurance_and_eClaims
SELECT customer_details FROM customers WHERE customer_details LIKE "%Diana%"
Find the names of customers whose name contains "Diana".
insurance_and_eClaims
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 the customers who have an deputy policy.