schema
stringlengths 144
5.45k
| question
stringlengths 16
224
| query
stringlengths 18
577
| hardness
stringclasses 5
values |
---|---|---|---|
CREATE TABLE county (County_Id number, County_name text, Population number, Zip_code text); CREATE TABLE party (Party_ID number, Year number, Party text, Governor text, Lieutenant_Governor text, Comptroller text, Attorney_General text, US_Senate text); CREATE TABLE election (Election_ID number, Counties_Represented text, District number, Delegate text, Party number, First_Elected number, Committee text);
|
Which committees have delegates from both democratic party and liberal party?
|
SELECT T1.Committee FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T2.Party = "Democratic" INTERSECT SELECT T1.Committee FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T2.Party = "Liberal"
|
extra
|
CREATE TABLE county (County_Id number, County_name text, Population number, Zip_code text); CREATE TABLE party (Party_ID number, Year number, Party text, Governor text, Lieutenant_Governor text, Comptroller text, Attorney_General text, US_Senate text); CREATE TABLE election (Election_ID number, Counties_Represented text, District number, Delegate text, Party number, First_Elected number, Committee text);
|
Find the committees that have delegates both from from the democratic party and the liberal party.
|
SELECT T1.Committee FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T2.Party = "Democratic" INTERSECT SELECT T1.Committee FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T2.Party = "Liberal"
|
extra
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
How many journalists are there?
|
SELECT count(*) FROM journalist
|
easy
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
List the names of journalists in ascending order of years working.
|
SELECT Name FROM journalist ORDER BY Years_working ASC
|
easy
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
What are the nationalities and ages of journalists?
|
SELECT Nationality , Age FROM journalist
|
medium
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
Show the names of journalists from "England" or "Wales".
|
SELECT Name FROM journalist WHERE Nationality = "England" OR Nationality = "Wales"
|
medium
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
What is the average number of years spent working as a journalist?
|
SELECT avg(Years_working) FROM journalist
|
easy
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
What is the nationality of the journalist with the largest number of years working?
|
SELECT Nationality FROM journalist ORDER BY Years_working DESC LIMIT 1
|
medium
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
Show the different nationalities and the number of journalists of each nationality.
|
SELECT Nationality , COUNT(*) FROM journalist GROUP BY Nationality
|
medium
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
Show the most common nationality for journalists.
|
SELECT Nationality FROM journalist GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1
|
hard
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
Show the nations that have both journalists with more than 10 years of working and journalists with less than 3 years of working.
|
SELECT Nationality FROM journalist WHERE Years_working > 10 INTERSECT SELECT Nationality FROM journalist WHERE Years_working < 3
|
hard
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
Show the dates, places, and names of events in descending order of the attendance.
|
SELECT Date , Name , venue FROM event ORDER BY Event_Attendance DESC
|
medium
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
Show the names of journalists and the dates of the events they reported.
|
SELECT T3.Name , T2.Date FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID
|
medium
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
Show the names of journalists and the names of the events they reported in ascending order
|
SELECT T3.Name , T2.Name FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID ORDER BY T2.Event_Attendance ASC
|
hard
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
Show the names of journalists and the number of events they reported.
|
SELECT T3.Name , COUNT(*) FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID GROUP BY T3.Name
|
hard
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
Show the names of journalists that have reported more than one event.
|
SELECT T3.Name FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID GROUP BY T3.Name HAVING COUNT(*) > 1
|
hard
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
List the names of journalists who have not reported any event.
|
SELECT Name FROM journalist WHERE journalist_ID NOT IN (SELECT journalist_ID FROM news_report)
|
hard
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
what are the average and maximum attendances of all events?
|
SELECT avg(Event_Attendance) , max(Event_Attendance) FROM event
|
medium
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
Find the average age and experience working length of journalists working on different role type.
|
SELECT avg(t1.age) , avg(Years_working) , t2.work_type FROM journalist AS t1 JOIN news_report AS t2 ON t1.journalist_id = t2.journalist_id GROUP BY t2.work_type
|
extra
|
CREATE TABLE event (Event_ID number, Date text, Venue text, Name text, Event_Attendance number); CREATE TABLE journalist (journalist_ID number, Name text, Nationality text, Age text, Years_working number); CREATE TABLE news_report (journalist_ID number, Event_ID number, Work_Type text);
|
List the event venues and names that have the top 2 most number of people attended.
|
SELECT venue , name FROM event ORDER BY Event_Attendance DESC LIMIT 2
|
medium
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
Show me all the restaurants.
|
SELECT ResName FROM Restaurant;
|
easy
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
What is the address of the restaurant Subway?
|
SELECT Address FROM Restaurant WHERE ResName = "Subway";
|
easy
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
What is the rating of the restaurant Subway?
|
SELECT Rating FROM Restaurant WHERE ResName = "Subway";
|
easy
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
List all restaurant types.
|
SELECT ResTypeName FROM Restaurant_Type;
|
easy
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
What is the description of the restaurant type Sandwich?
|
SELECT ResTypeDescription FROM Restaurant_Type WHERE ResTypeName = "Sandwich";
|
easy
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
Which restaurants have highest rating? List the restaurant name and its rating.
|
SELECT ResName , Rating FROM Restaurant ORDER BY Rating DESC LIMIT 1;
|
medium
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
What is the age of student Linda Smith?
|
SELECT Age FROM Student WHERE Fname = "Linda" AND Lname = "Smith";
|
medium
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
What is the gender of the student Linda Smith?
|
SELECT Sex FROM Student WHERE Fname = "Linda" AND Lname = "Smith";
|
medium
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
List all students' first names and last names who majored in 600.
|
SELECT Fname , Lname FROM Student WHERE Major = 600;
|
medium
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
Which city does student Linda Smith live in?
|
SELECT city_code FROM Student WHERE Fname = "Linda" AND Lname = "Smith";
|
medium
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
Advisor 1121 has how many students?
|
SELECT count(*) FROM Student WHERE Advisor = 1121;
|
easy
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
Which Advisor has most of students? List advisor and the number of students.
|
SELECT Advisor , count(*) FROM Student GROUP BY Advisor ORDER BY count(Advisor) DESC LIMIT 1;
|
hard
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
Which major has least number of students? List the major and the number of students.
|
SELECT Major , count(*) FROM Student GROUP BY Major ORDER BY count(Major) ASC LIMIT 1;
|
hard
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
Which major has between 2 and 30 number of students? List major and the number of students.
|
SELECT Major , count(*) FROM Student GROUP BY Major HAVING count(Major) BETWEEN 2 AND 30;
|
medium
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
Which student's age is older than 18 and is majoring in 600? List each student's first and last name.
|
SELECT Fname , Lname FROM Student WHERE Age > 18 AND Major = 600;
|
medium
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
List all female students age is older than 18 who is not majoring in 600. List students' first name and last name.
|
SELECT Fname , Lname FROM Student WHERE Age > 18 AND Major != 600 AND Sex = 'F';
|
medium
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
How many restaurant is the Sandwich type restaurant?
|
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'
|
hard
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
How long does student Linda Smith spend on the restaurant in total?
|
SELECT sum(Spent) FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID WHERE Student.Fname = "Linda" AND Student.Lname = "Smith";
|
medium
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
How many times has the student Linda Smith visited Subway?
|
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";
|
hard
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
When did Linda Smith visit Subway?
|
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";
|
hard
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
At which restaurant did the students spend the least amount of time? List restaurant and the time students spent on in total.
|
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;
|
extra
|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Restaurant (ResID number, ResName text, Address text, Rating number); CREATE TABLE Type_Of_Restaurant (ResID number, ResTypeID number); CREATE TABLE Restaurant_Type (ResTypeID number, ResTypeName text, ResTypeDescription text); CREATE TABLE Visits_Restaurant (StuID number, ResID number, Time time, Spent number);
|
Which student visited restaurant most often? List student's first name and last name.
|
SELECT Student.Fname , Student.Lname FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID GROUP BY Student.StuID ORDER BY count(*) DESC LIMIT 1;
|
extra
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
Find the ids of orders whose status is 'Success'.
|
SELECT actual_order_id FROM actual_orders WHERE order_status_code = 'Success'
|
easy
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
Find the name and price of the product that has been ordered the greatest number of times.
|
SELECT t1.product_name , t1.product_price FROM products AS t1 JOIN regular_order_products AS t2 ON t1.product_id = t2.product_id GROUP BY t2.product_id ORDER BY count(*) DESC LIMIT 1
|
extra
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
Find the number of customers in total.
|
SELECT count(*) FROM customers
|
easy
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
How many different payment methods are there?
|
SELECT count(DISTINCT payment_method) FROM customers
|
easy
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
Show the details of all trucks in the order of their license number.
|
SELECT truck_details FROM trucks ORDER BY truck_licence_number
|
easy
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
Find the name of the most expensive product.
|
SELECT product_name FROM products ORDER BY product_price DESC LIMIT 1
|
medium
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
Find the names of customers who are not living in the state of California.
|
SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t3.state_province_county = 'California'
|
hard
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
List the names and emails of customers who payed by Visa card.
|
SELECT customer_email , customer_name FROM customers WHERE payment_method = 'Visa'
|
medium
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
Find the names and phone numbers of customers living in California state.
|
SELECT t1.customer_name , t1.customer_phone FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t3.state_province_county = 'California'
|
hard
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
Find the states which do not have any employee in their record.
|
SELECT state_province_county FROM addresses WHERE address_id NOT IN (SELECT employee_address_id FROM Employees)
|
hard
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
List the names, phone numbers, and emails of all customers sorted by their dates of becoming customers.
|
SELECT customer_name , customer_phone , customer_email FROM Customers ORDER BY date_became_customer
|
medium
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
Find the name of the first 5 customers.
|
SELECT customer_name FROM Customers ORDER BY date_became_customer LIMIT 5
|
medium
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
Find the payment method that is used most frequently.
|
SELECT payment_method FROM Customers GROUP BY payment_method ORDER BY count(*) DESC LIMIT 1
|
hard
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
List the names of all routes in alphabetic order.
|
SELECT route_name FROM Delivery_Routes ORDER BY route_name
|
easy
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
Find the name of route that has the highest number of deliveries.
|
SELECT t1.route_name FROM Delivery_Routes AS t1 JOIN Delivery_Route_Locations AS t2 ON t1.route_id = t2.route_id GROUP BY t1.route_id ORDER BY count(*) DESC LIMIT 1
|
extra
|
CREATE TABLE Products (product_id number, product_name text, product_price number, product_description text); CREATE TABLE Addresses (address_id number, address_details text, city text, zip_postcode text, state_province_county text, country text); CREATE TABLE Customers (customer_id number, payment_method text, customer_name text, customer_phone text, customer_email text, date_became_customer time); CREATE TABLE Regular_Orders (regular_order_id number, distributer_id number); CREATE TABLE Regular_Order_Products (regular_order_id number, product_id number); CREATE TABLE Actual_Orders (actual_order_id number, order_status_code text, regular_order_id number, actual_order_date time); CREATE TABLE Actual_Order_Products (actual_order_id number, product_id number); CREATE TABLE Customer_Addresses (customer_id number, address_id number, date_from time, address_type text, date_to time); CREATE TABLE Delivery_Routes (route_id number, route_name text, other_route_details text); CREATE TABLE Delivery_Route_Locations (location_code text, route_id number, location_address_id number, location_name text); CREATE TABLE Trucks (truck_id number, truck_licence_number text, truck_details text); CREATE TABLE Employees (employee_id number, employee_address_id number, employee_name text, employee_phone text); CREATE TABLE Order_Deliveries (location_code text, actual_order_id number, delivery_status_code text, driver_employee_id number, truck_id number, delivery_date time);
|
List the state names and the number of customers living in each state.
|
SELECT t2.state_province_county , count(*) FROM customer_addresses AS t1 JOIN addresses AS t2 ON t1.address_id = t2.address_id GROUP BY t2.state_province_county
|
medium
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
How many authors are there?
|
SELECT count(*) FROM authors
|
easy
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Count the number of authors.
|
SELECT count(*) FROM authors
|
easy
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
How many institutions are there?
|
SELECT count(*) FROM inst
|
easy
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Count the number of institutions.
|
SELECT count(*) FROM inst
|
easy
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
How many papers are published in total?
|
SELECT count(*) FROM papers
|
easy
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Count the number of total papers.
|
SELECT count(*) FROM papers
|
easy
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
What are the titles of papers published by "Jeremy Gibbons"?
|
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t1.fname = "Jeremy" AND t1.lname = "Gibbons"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find the titles of all the papers written by "Jeremy Gibbons"
|
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t1.fname = "Jeremy" AND t1.lname = "Gibbons"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find all the papers published by "Aaron Turon".
|
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t1.fname = "Aaron" AND t1.lname = "Turon"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find the titles of all the papers written by "Aaron Turon".
|
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t1.fname = "Aaron" AND t1.lname = "Turon"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
How many papers have "Atsushi Ohori" published?
|
SELECT count(*) FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t1.fname = "Atsushi" AND t1.lname = "Ohori"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
How many papers are "Atsushi Ohori" the author of?
|
SELECT count(*) FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t1.fname = "Atsushi" AND t1.lname = "Ohori"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
What is the name of the institution that "Matthias Blume" belongs to?
|
SELECT DISTINCT t3.name FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t1.fname = "Matthias" AND t1.lname = "Blume"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Which institution is the author "Matthias Blume" belong to? Give me the name of the institution.
|
SELECT DISTINCT t3.name FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t1.fname = "Matthias" AND t1.lname = "Blume"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Which institution does "Katsuhiro Ueno" belong to?
|
SELECT DISTINCT t3.name FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t1.fname = "Katsuhiro" AND t1.lname = "Ueno"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
What is the name of the institution the author "Katsuhiro Ueno" belongs to?
|
SELECT DISTINCT t3.name FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t1.fname = "Katsuhiro" AND t1.lname = "Ueno"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Who belong to the institution "University of Oxford"? Show the first names and last names.
|
SELECT DISTINCT t1.fname , t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "University of Oxford"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find the first names and last names of the authors whose institution affiliation is "University of Oxford".
|
SELECT DISTINCT t1.fname , t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "University of Oxford"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Which authors belong to the institution "Google"? Show the first names and last names.
|
SELECT DISTINCT t1.fname , t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "Google"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find the first names and last names of the authors whose institution affiliation is "Google".
|
SELECT DISTINCT t1.fname , t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "Google"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
What are the last names of the author of the paper titled "Binders Unbound"?
|
SELECT t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title = "Binders Unbound"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Who is the author of the paper titled "Binders Unbound"? Give me the last name.
|
SELECT t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title = "Binders Unbound"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find the first and last name of the author(s) who wrote the paper "Nameless, Painless".
|
SELECT t1.fname , t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title = "Nameless , Painless"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
What are the first and last name of the author who published the paper titled "Nameless, Painless"?
|
SELECT t1.fname , t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title = "Nameless , Painless"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
What are the papers published under the institution "Indiana University"?
|
SELECT DISTINCT t1.title FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "Indiana University"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
List the titles of the papers whose authors are from the institution "Indiana University".
|
SELECT DISTINCT t1.title FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "Indiana University"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find all the papers published by the institution "Google".
|
SELECT DISTINCT t1.title FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "Google"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Which papers were written by authors from the institution "Google"?
|
SELECT DISTINCT t1.title FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "Google"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
How many papers are published by the institution "Tokohu University"?
|
SELECT count(DISTINCT t1.title) FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "Tokohu University"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find the number of papers published by authors from the institution "Tokohu University".
|
SELECT count(DISTINCT t1.title) FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "Tokohu University"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find the number of papers published by the institution "University of Pennsylvania".
|
SELECT count(DISTINCT t1.title) FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "University of Pennsylvania"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
How many papers are written by authors from the institution "University of Pennsylvania"?
|
SELECT count(DISTINCT t1.title) FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "University of Pennsylvania"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find the papers which have "Olin Shivers" as an author.
|
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t1.fname = "Olin" AND t1.lname = "Shivers"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Which papers did the author "Olin Shivers" write? Give me the paper titles.
|
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t1.fname = "Olin" AND t1.lname = "Shivers"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Which papers have "Stephanie Weirich" as an author?
|
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t1.fname = "Stephanie" AND t1.lname = "Weirich"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find the titles of the papers the author "Stephanie Weirich" wrote.
|
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t1.fname = "Stephanie" AND t1.lname = "Weirich"
|
hard
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Which paper is published in an institution in "USA" and have "Turon" as its second author?
|
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid JOIN inst AS t4 ON t2.instid = t4.instid WHERE t4.country = "USA" AND t2.authorder = 2 AND t1.lname = "Turon"
|
extra
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find papers whose second author has last name "Turon" and is affiliated with an institution in the country "USA".
|
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid JOIN inst AS t4 ON t2.instid = t4.instid WHERE t4.country = "USA" AND t2.authorder = 2 AND t1.lname = "Turon"
|
extra
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Find the titles of papers whose first author is affiliated with an institution in the country "Japan" and has last name "Ohori"?
|
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid JOIN inst AS t4 ON t2.instid = t4.instid WHERE t4.country = "Japan" AND t2.authorder = 1 AND t1.lname = "Ohori"
|
extra
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Which papers' first author is affiliated with an institution in the country "Japan" and has last name "Ohori"? Give me the titles of the papers.
|
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid JOIN inst AS t4 ON t2.instid = t4.instid WHERE t4.country = "Japan" AND t2.authorder = 1 AND t1.lname = "Ohori"
|
extra
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
What is the last name of the author that has published the most papers?
|
SELECT t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid GROUP BY t1.fname , t1.lname ORDER BY count(*) DESC LIMIT 1
|
extra
|
CREATE TABLE Inst (instID number, name text, country text); CREATE TABLE Authors (authID number, lname text, fname text); CREATE TABLE Papers (paperID number, title text); CREATE TABLE Authorship (authID number, instID number, paperID number, authOrder number);
|
Which author has written the most papers? Find his or her last name.
|
SELECT t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid GROUP BY t1.fname , t1.lname ORDER BY count(*) DESC LIMIT 1
|
extra
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.