Search is not available for this dataset
db_id
stringlengths
3
31
query
stringlengths
20
523
question
stringlengths
3
224
schema
stringlengths
589
322M
query_res
stringlengths
0
363k
game_1
SELECT StuID FROM Student WHERE major = 600 INTERSECT SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y'
Show student ids who are on scholarship and have major 600.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1002,) (1003,) (1015,) (1019,)
game_1
SELECT StuID FROM Student WHERE major = 600 INTERSECT SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y'
What are the student ids for those on scholarship in major number 600?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1002,) (1003,) (1015,) (1019,)
game_1
SELECT StuID FROM Student WHERE sex = 'F' INTERSECT SELECT StuID FROM Sportsinfo WHERE sportname = "Football"
Show student ids who are female and play football.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1002,) (1003,)
game_1
SELECT StuID FROM Student WHERE sex = 'F' INTERSECT SELECT StuID FROM Sportsinfo WHERE sportname = "Football"
What are the ids of all female students who play football?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1002,) (1003,)
game_1
SELECT StuID FROM Student WHERE sex = 'M' EXCEPT SELECT StuID FROM Sportsinfo WHERE sportname = "Football"
Show all male student ids who don't play football.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1004,) (1005,) (1006,) (1009,) (1010,) (1011,) (1012,) (1014,) (1016,) (1017,) (1018,) (1019,) (1020,) (1021,) (1022,) (1023,) (1025,) (1026,) (1027,) (1028,) (1029,) (1032,) (1033,) (1034,)
game_1
SELECT StuID FROM Student WHERE sex = 'M' EXCEPT SELECT StuID FROM Sportsinfo WHERE sportname = "Football"
What are the ids of all male students who do not play football?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1004,) (1005,) (1006,) (1009,) (1010,) (1011,) (1012,) (1014,) (1016,) (1017,) (1018,) (1019,) (1020,) (1021,) (1022,) (1023,) (1025,) (1026,) (1027,) (1028,) (1029,) (1032,) (1033,) (1034,)
game_1
SELECT sum(hoursperweek) , sum(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.Fname = "David" AND T2.Lname = "Shieber"
Show total hours per week and number of games played for student David Shieber.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(15, 64)
game_1
SELECT sum(hoursperweek) , sum(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.Fname = "David" AND T2.Lname = "Shieber"
What is the total number of hours per work and number of games played by David Shieber?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(15, 64)
game_1
SELECT sum(hoursperweek) , sum(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.age < 20
Show total hours per week and number of games played for students under 20.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(158, 257)
game_1
SELECT sum(hoursperweek) , sum(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.age < 20
What is the total number of hours per week and number of games played by students under 20?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(158, 257)
game_1
SELECT count(DISTINCT StuID) FROM Plays_games
How many students play video games?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(5,)
game_1
SELECT count(DISTINCT StuID) FROM Plays_games
How many different students play games?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(5,)
game_1
SELECT StuID FROM Student EXCEPT SELECT StuID FROM Plays_games
Show ids of students who don't play video game.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1002,) (1003,) (1004,) (1005,) (1006,) (1009,) (1011,) (1012,) (1014,) (1015,) (1016,) (1017,) (1018,) (1019,) (1020,) (1021,) (1022,) (1023,) (1024,) (1025,) (1026,) (1027,) (1028,) (1029,) (1030,) (1031,) (1033,) (1034,) (1035,)
game_1
SELECT StuID FROM Student EXCEPT SELECT StuID FROM Plays_games
What are the ids of all students who are not video game players?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1002,) (1003,) (1004,) (1005,) (1006,) (1009,) (1011,) (1012,) (1014,) (1015,) (1016,) (1017,) (1018,) (1019,) (1020,) (1021,) (1022,) (1023,) (1024,) (1025,) (1026,) (1027,) (1028,) (1029,) (1030,) (1031,) (1033,) (1034,) (1035,)
game_1
SELECT StuID FROM Sportsinfo INTERSECT SELECT StuID FROM Plays_games
Show ids of students who play video game and play sports.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1001,)
game_1
SELECT StuID FROM Sportsinfo INTERSECT SELECT StuID FROM Plays_games
What are the ids of all students who played video games and sports?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1001,)
game_1
SELECT gameid , sum(hours_played) FROM Plays_games GROUP BY gameid
Show all game ids and the number of hours played.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1, 82) (2, 25) (3, 150) (4, 1000) (5, 51) (6, 1337)
game_1
SELECT gameid , sum(hours_played) FROM Plays_games GROUP BY gameid
What are ids and total number of hours played for each game?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1, 82) (2, 25) (3, 150) (4, 1000) (5, 51) (6, 1337)
game_1
SELECT Stuid , sum(hours_played) FROM Plays_games GROUP BY Stuid
Show all student ids and the number of hours played.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1001, 51) (1007, 1000) (1008, 100) (1010, 1337) (1032, 157)
game_1
SELECT Stuid , sum(hours_played) FROM Plays_games GROUP BY Stuid
What are the ids of all students and number of hours played?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
(1001, 51) (1007, 1000) (1008, 100) (1010, 1337) (1032, 157)
game_1
SELECT gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid GROUP BY T1.gameid ORDER BY sum(hours_played) DESC LIMIT 1
Show the game name that has most number of hours played.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
('Works of Widenius',)
game_1
SELECT gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid GROUP BY T1.gameid ORDER BY sum(hours_played) DESC LIMIT 1
What is the name of the game that has been played the most?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
('Works of Widenius',)
game_1
SELECT gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid GROUP BY T1.gameid HAVING sum(hours_played) >= 1000
Show all game names played by at least 1000 hours.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
('Europe is the Universe',) ('Works of Widenius',)
game_1
SELECT gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid GROUP BY T1.gameid HAVING sum(hours_played) >= 1000
What are the names of all the games that have been played for at least 1000 hours?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
('Europe is the Universe',) ('Works of Widenius',)
game_1
SELECT Gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid JOIN Student AS T3 ON T3.Stuid = T1.Stuid WHERE T3.Lname = "Smith" AND T3.Fname = "Linda"
Show all game names played by Linda Smith
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
('RNG Stone',) ('The Vanishing of Eric Calder',) ('Call of Destiny',)
game_1
SELECT Gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid JOIN Student AS T3 ON T3.Stuid = T1.Stuid WHERE T3.Lname = "Smith" AND T3.Fname = "Linda"
What are the names of all games played by Linda Smith?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
('RNG Stone',) ('The Vanishing of Eric Calder',) ('Call of Destiny',)
game_1
SELECT T2.lname , T2.fname FROM SportsInfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T1.SportName = "Football" OR T1.SportName = "Lacrosse"
Find the last and first name of students who are playing Football or Lacrosse.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
('Kim', 'Tracy') ('Jones', 'Shiela') ('Gompers', 'Paul') ('Lee', 'Susan') ('Leighton', 'Michael')
game_1
SELECT T2.lname , T2.fname FROM SportsInfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T1.SportName = "Football" OR T1.SportName = "Lacrosse"
What is the first and last name of all students who play Football or Lacrosse?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
('Kim', 'Tracy') ('Jones', 'Shiela') ('Gompers', 'Paul') ('Lee', 'Susan') ('Leighton', 'Michael')
game_1
SELECT fname , age FROM Student WHERE StuID IN (SELECT StuID FROM Sportsinfo WHERE SportName = "Football" INTERSECT SELECT StuID FROM Sportsinfo WHERE SportName = "Lacrosse")
Find the first name and age of the students who are playing both Football and Lacrosse.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
game_1
SELECT fname , age FROM Student WHERE StuID IN (SELECT StuID FROM Sportsinfo WHERE SportName = "Football" INTERSECT SELECT StuID FROM Sportsinfo WHERE SportName = "Lacrosse")
What are the first names and ages of all students who are playing both Football and Lacrosse?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
game_1
SELECT lname , sex FROM Student WHERE StuID IN (SELECT T1.StuID FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.GameID = T2.GameID WHERE T2.Gname = "Call of Destiny" INTERSECT SELECT T1.StuID FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.GameID = T2.GameID WHERE T2.Gname = "Works of Widenius")
Find the last name and gender of the students who are playing both Call of Destiny and Works of Widenius games.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
game_1
SELECT lname , sex FROM Student WHERE StuID IN (SELECT T1.StuID FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.GameID = T2.GameID WHERE T2.Gname = "Call of Destiny" INTERSECT SELECT T1.StuID FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.GameID = T2.GameID WHERE T2.Gname = "Works of Widenius")
what is the last name and gender of all students who played both Call of Destiny and Works of Widenius?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Video_Games ( G...
customers_and_addresses
SELECT customer_name FROM customers
Find the name of all customers.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Dr. Julia Wuckert MD',) ('Tillman Ernser',) ('Rodrick Heaney',) ('Prof. Alexzander Hamill',) ('Prof. Reyes Berge II',) ('Maudie Kertzmann',) ('Mozell Morissette',) ('Eunice Morar',) ('Devin Mills',) ('Kitty Padberg III',) ('Salvatore Tillman',) ('Clifford Pagac',) ('Miss Aliyah Witting',) ('Alexane Kilback',) ('Prof....
customers_and_addresses
SELECT customer_name FROM customers
What are the names of all the customers?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Dr. Julia Wuckert MD',) ('Tillman Ernser',) ('Rodrick Heaney',) ('Prof. Alexzander Hamill',) ('Prof. Reyes Berge II',) ('Maudie Kertzmann',) ('Mozell Morissette',) ('Eunice Morar',) ('Devin Mills',) ('Kitty Padberg III',) ('Salvatore Tillman',) ('Clifford Pagac',) ('Miss Aliyah Witting',) ('Alexane Kilback',) ('Prof....
customers_and_addresses
SELECT count(*) FROM customers
How many customers are there?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(15,)
customers_and_addresses
SELECT count(*) FROM customers
Return the total number of distinct customers.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(15,)
customers_and_addresses
SELECT avg(order_quantity) FROM order_items
What is the average amount of items ordered in each order?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(6.333333333333333,)
customers_and_addresses
SELECT avg(order_quantity) FROM order_items
Find the average order quantity per order.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(6.333333333333333,)
customers_and_addresses
SELECT customer_name FROM customers WHERE payment_method = "Cash"
What are the names of customers who use payment method "Cash"?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Dr. Julia Wuckert MD',) ('Maudie Kertzmann',) ('Kitty Padberg III',) ('Prof. Ibrahim Bashirian',)
customers_and_addresses
SELECT customer_name FROM customers WHERE payment_method = "Cash"
Which customers use "Cash" for payment method? Return the customer names.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Dr. Julia Wuckert MD',) ('Maudie Kertzmann',) ('Kitty Padberg III',) ('Prof. Ibrahim Bashirian',)
customers_and_addresses
SELECT date_became_customer FROM customers WHERE customer_id BETWEEN 10 AND 20
Find the "date became customers" of the customers whose ID is between 10 and 20.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('2018-03-22 18:09:09',) ('2018-03-04 00:17:48',) ('2018-02-24 10:24:23',) ('2018-03-05 07:19:45',) ('2018-03-08 01:17:31',) ('2018-03-15 02:54:27',)
customers_and_addresses
SELECT date_became_customer FROM customers WHERE customer_id BETWEEN 10 AND 20
What are the dates when customers with ids between 10 and 20 became customers?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('2018-03-22 18:09:09',) ('2018-03-04 00:17:48',) ('2018-02-24 10:24:23',) ('2018-03-05 07:19:45',) ('2018-03-08 01:17:31',) ('2018-03-15 02:54:27',)
customers_and_addresses
SELECT payment_method FROM customers GROUP BY payment_method ORDER BY count(*) DESC LIMIT 1
Which payment method is used by most customers?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Cheque',)
customers_and_addresses
SELECT payment_method FROM customers GROUP BY payment_method ORDER BY count(*) DESC LIMIT 1
Find the payment method that is used most frequently.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Cheque',)
customers_and_addresses
SELECT customer_name FROM customers WHERE payment_method = (SELECT payment_method FROM customers GROUP BY payment_method ORDER BY count(*) DESC LIMIT 1)
What are the names of customers using the most popular payment method?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Tillman Ernser',) ('Prof. Reyes Berge II',) ('Devin Mills',) ('Salvatore Tillman',) ('Clifford Pagac',) ('Alexane Kilback',)
customers_and_addresses
SELECT customer_name FROM customers WHERE payment_method = (SELECT payment_method FROM customers GROUP BY payment_method ORDER BY count(*) DESC LIMIT 1)
Find the name of the customers who use the most frequently used payment method.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Tillman Ernser',) ('Prof. Reyes Berge II',) ('Devin Mills',) ('Salvatore Tillman',) ('Clifford Pagac',) ('Alexane Kilback',)
customers_and_addresses
SELECT DISTINCT payment_method FROM customers
What are all the payment methods?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Cash',) ('Cheque',) ('Credit Card',)
customers_and_addresses
SELECT DISTINCT payment_method FROM customers
Return all the distinct payment methods used by customers.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Cash',) ('Cheque',) ('Credit Card',)
customers_and_addresses
SELECT DISTINCT product_details FROM products
What are the details of all products?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Americano',) ('Dove Chocolate',) ('Latte',)
customers_and_addresses
SELECT DISTINCT product_details FROM products
Return the the details of all products.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Americano',) ('Dove Chocolate',) ('Latte',)
customers_and_addresses
SELECT customer_name FROM customers WHERE customer_name LIKE "%Alex%"
Find the name of all customers whose name contains "Alex".
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Prof. Alexzander Hamill',) ('Alexane Kilback',)
customers_and_addresses
SELECT customer_name FROM customers WHERE customer_name LIKE "%Alex%"
Which customer's name contains "Alex"? Find the full name.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Prof. Alexzander Hamill',) ('Alexane Kilback',)
customers_and_addresses
SELECT product_details FROM products WHERE product_details LIKE "%Latte%" OR product_details LIKE "%Americano%"
Find the detail of products whose detail contains the word "Latte" or the word "Americano"
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Americano',) ('Latte',)
customers_and_addresses
SELECT product_details FROM products WHERE product_details LIKE "%Latte%" OR product_details LIKE "%Americano%"
Which product's detail contains the word "Latte" or "Americano"? Return the full detail.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Americano',) ('Latte',)
customers_and_addresses
SELECT t3.address_content 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 t1.customer_name = "Maudie Kertzmann"
What is the address content of the customer named "Maudie Kertzmann"?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('59540 Grover Wells Apt. 814',)
customers_and_addresses
SELECT t3.address_content 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 t1.customer_name = "Maudie Kertzmann"
Return the address content for the customer whose name is "Maudie Kertzmann".
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('59540 Grover Wells Apt. 814',)
customers_and_addresses
SELECT count(*) 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.city = "Lake Geovannyton"
How many customers are living in city "Lake Geovannyton"?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(3,)
customers_and_addresses
SELECT count(*) 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.city = "Lake Geovannyton"
Find the number of customers who live in the city called Lake Geovannyton.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(3,)
customers_and_addresses
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 = "Colorado"
Find the name of customers who are living in Colorado?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Miss Aliyah Witting',) ('Eunice Morar',)
customers_and_addresses
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 = "Colorado"
What are the names of customers who live in Colorado state?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Miss Aliyah Witting',) ('Eunice Morar',)
customers_and_addresses
SELECT city FROM addresses WHERE city NOT IN ( SELECT DISTINCT t3.city 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)
Find the list of cities that no customer is living in.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Lucasville',) ('New Sabryna',) ('Gleasonmouth',) ('South Bellaland',) ('Felicityfort',) ('East Julianaside',) ('Port Lilyan',)
customers_and_addresses
SELECT city FROM addresses WHERE city NOT IN ( SELECT DISTINCT t3.city 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)
What are the cities no customers live in?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Lucasville',) ('New Sabryna',) ('Gleasonmouth',) ('South Bellaland',) ('Felicityfort',) ('East Julianaside',) ('Port Lilyan',)
customers_and_addresses
SELECT t3.city 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 GROUP BY t3.city ORDER BY count(*) DESC LIMIT 1
Which city has the most customers living in?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Lake Geovannyton',)
customers_and_addresses
SELECT t3.city 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 GROUP BY t3.city ORDER BY count(*) DESC LIMIT 1
Find the city where the most customers live.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Lake Geovannyton',)
customers_and_addresses
SELECT DISTINCT city FROM addresses
Retrieve the list of all cities.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Lucasville',) ('New Sabryna',) ('Reingertown',) ('Gleasonmouth',) ('Stantonville',) ('South Meghanview',) ('Lake Walterton',) ('South Bellaland',) ('Felicityfort',) ('East Julianaside',) ('Lake Geovannyton',) ('New Terrillport',) ('Port Lilyan',) ('Lake Ryann',) ('East Pascale',)
customers_and_addresses
SELECT DISTINCT city FROM addresses
List all the distinct cities
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Lucasville',) ('New Sabryna',) ('Reingertown',) ('Gleasonmouth',) ('Stantonville',) ('South Meghanview',) ('Lake Walterton',) ('South Bellaland',) ('Felicityfort',) ('East Julianaside',) ('Lake Geovannyton',) ('New Terrillport',) ('Port Lilyan',) ('Lake Ryann',) ('East Pascale',)
customers_and_addresses
SELECT city FROM addresses WHERE zip_postcode = 255
Find the city with post code 255.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Reingertown',)
customers_and_addresses
SELECT city FROM addresses WHERE zip_postcode = 255
Which city is post code 255 located in?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Reingertown',)
customers_and_addresses
SELECT state_province_county , country FROM addresses WHERE zip_postcode LIKE "4%"
Find the state and country of all cities with post code starting with 4.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Colorado', 'USA') ('Texas', 'USA') ('Kentucky', 'USA')
customers_and_addresses
SELECT state_province_county , country FROM addresses WHERE zip_postcode LIKE "4%"
What are the state and country of all the cities that have post codes starting with 4.\
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Colorado', 'USA') ('Texas', 'USA') ('Kentucky', 'USA')
customers_and_addresses
SELECT country FROM addresses GROUP BY country HAVING count(address_id) > 4
List the countries having more than 4 addresses listed.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('USA',)
customers_and_addresses
SELECT country FROM addresses GROUP BY country HAVING count(address_id) > 4
For which countries are there more than four distinct addresses listed?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('USA',)
customers_and_addresses
SELECT channel_code FROM customer_contact_channels GROUP BY channel_code HAVING count(customer_id) < 5
List all the contact channel codes that were used less than 5 times.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Cell',) ('Email',) ('Fax',) ('Mobile',)
customers_and_addresses
SELECT channel_code FROM customer_contact_channels GROUP BY channel_code HAVING count(customer_id) < 5
Which contact channel codes were used less than 5 times?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Cell',) ('Email',) ('Fax',) ('Mobile',)
customers_and_addresses
SELECT DISTINCT channel_code FROM customers AS t1 JOIN customer_contact_channels AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name = "Tillman Ernser"
Which contact channel has been used by the customer with name "Tillman Ernser"?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Email',) ('Cell',) ('Handheld',)
customers_and_addresses
SELECT DISTINCT channel_code FROM customers AS t1 JOIN customer_contact_channels AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name = "Tillman Ernser"
Find the contact channel code that was used by the customer named "Tillman Ernser".
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Email',) ('Cell',) ('Handheld',)
customers_and_addresses
SELECT max(t2.active_to_date) FROM customers AS t1 JOIN customer_contact_channels AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name = "Tillman Ernser"
What is the "active to date" of the latest contact channel used by "Tillman Ernser"?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('2018-03-23 01:30:52',)
customers_and_addresses
SELECT max(t2.active_to_date) FROM customers AS t1 JOIN customer_contact_channels AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name = "Tillman Ernser"
Return the the "active to date" of the latest contact channel used by the customer named "Tillman Ernser".
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('2018-03-23 01:30:52',)
customers_and_addresses
SELECT avg(active_to_date - active_from_date) FROM customer_contact_channels
What is the average time span of contact channels in the database?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(0.85,)
customers_and_addresses
SELECT avg(active_to_date - active_from_date) FROM customer_contact_channels
Compute the average active time span of contact channels.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(0.85,)
customers_and_addresses
SELECT channel_code , contact_number FROM customer_contact_channels WHERE active_to_date - active_from_date = (SELECT active_to_date - active_from_date FROM customer_contact_channels ORDER BY (active_to_date - active_from_date) DESC LIMIT 1)
What is the channel code and contact number of the customer contact channel that was active for the longest time?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Email', '940.035.6435x0225') ('Email', '189.449.8326x7607') ('Email', '958-653-2640') ('Cell', '(165)527-5756x2419') ('Cell', '1-077-864-0102') ('Handheld', '06068550461') ('Handheld', '542.983.0224') ('Handheld', '(379)834-0867x267') ('Handheld', '(620)266-6990x8590') ('Fax', '(068)656-5276x84466') ('Fax', '496-074-...
customers_and_addresses
SELECT channel_code , contact_number FROM customer_contact_channels WHERE active_to_date - active_from_date = (SELECT active_to_date - active_from_date FROM customer_contact_channels ORDER BY (active_to_date - active_from_date) DESC LIMIT 1)
Return the channel code and contact number of the customer contact channel whose active duration was the longest.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Email', '940.035.6435x0225') ('Email', '189.449.8326x7607') ('Email', '958-653-2640') ('Cell', '(165)527-5756x2419') ('Cell', '1-077-864-0102') ('Handheld', '06068550461') ('Handheld', '542.983.0224') ('Handheld', '(379)834-0867x267') ('Handheld', '(620)266-6990x8590') ('Fax', '(068)656-5276x84466') ('Fax', '496-074-...
customers_and_addresses
SELECT t1.customer_name , t2.active_from_date FROM customers AS t1 JOIN customer_contact_channels AS t2 ON t1.customer_id = t2.customer_id WHERE t2.channel_code = 'Email'
Find the name and active date of the customer that use email as the contact channel.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Devin Mills', '2017-12-07 18:18:15') ('Tillman Ernser', '2017-04-07 04:51:41') ('Devin Mills', '2017-05-25 16:08:45') ('Tillman Ernser', '2018-01-05 21:42:56')
customers_and_addresses
SELECT t1.customer_name , t2.active_from_date FROM customers AS t1 JOIN customer_contact_channels AS t2 ON t1.customer_id = t2.customer_id WHERE t2.channel_code = 'Email'
What are the name and active date of the customers whose contact channel code is email?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Devin Mills', '2017-12-07 18:18:15') ('Tillman Ernser', '2017-04-07 04:51:41') ('Devin Mills', '2017-05-25 16:08:45') ('Tillman Ernser', '2018-01-05 21:42:56')
customers_and_addresses
SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id WHERE t3.order_quantity = ( SELECT max(order_quantity) FROM order_items)
What is the name of the customer that made the order with the largest quantity?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Clifford Pagac',) ('Rodrick Heaney',) ('Prof. Alexzander Hamill',) ('Kitty Padberg III',) ('Clifford Pagac',)
customers_and_addresses
SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id WHERE t3.order_quantity = ( SELECT max(order_quantity) FROM order_items)
Find the name of the customer who made the order of the largest amount of goods.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Clifford Pagac',) ('Rodrick Heaney',) ('Prof. Alexzander Hamill',) ('Kitty Padberg III',) ('Clifford Pagac',)
customers_and_addresses
SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id GROUP BY t1.customer_name ORDER BY sum(t3.order_quantity) DESC LIMIT 1
What is the name of the customer that has purchased the most items?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Clifford Pagac',)
customers_and_addresses
SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id GROUP BY t1.customer_name ORDER BY sum(t3.order_quantity) DESC LIMIT 1
Give me the name of the customer who ordered the most items in total.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Clifford Pagac',)
customers_and_addresses
SELECT t1.payment_method FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id GROUP BY t1.customer_name ORDER BY sum(t3.order_quantity) LIMIT 1
What is the payment method of the customer that has purchased the least quantity of items?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Credit Card',)
customers_and_addresses
SELECT t1.payment_method FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id GROUP BY t1.customer_name ORDER BY sum(t3.order_quantity) LIMIT 1
Tell me the payment method used by the customer who ordered the least amount of goods in total.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Credit Card',)
customers_and_addresses
SELECT count(DISTINCT t3.product_id) FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id WHERE t1.customer_name = "Rodrick Heaney"
How many types of products have Rodrick Heaney bought in total?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(2,)
customers_and_addresses
SELECT count(DISTINCT t3.product_id) FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id WHERE t1.customer_name = "Rodrick Heaney"
Find the number of distinct products Rodrick Heaney has bought so far.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(2,)
customers_and_addresses
SELECT sum(t3.order_quantity) FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id WHERE t1.customer_name = "Rodrick Heaney"
What is the total quantity of products purchased by "Rodrick Heaney"?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(21,)
customers_and_addresses
SELECT sum(t3.order_quantity) FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id WHERE t1.customer_name = "Rodrick Heaney"
Tell me the total quantity of products bought by the customer called "Rodrick Heaney".
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(21,)
customers_and_addresses
SELECT count(DISTINCT customer_id) FROM customer_orders WHERE order_status = "Cancelled"
How many customers have at least one order with status "Cancelled"?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(7,)
customers_and_addresses
SELECT count(DISTINCT customer_id) FROM customer_orders WHERE order_status = "Cancelled"
Return the number of customers who have at least one order with "Cancelled" status.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(7,)
customers_and_addresses
SELECT count(*) FROM customer_orders WHERE order_details = "Second time"
How many orders have detail "Second time"?
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(5,)
customers_and_addresses
SELECT count(*) FROM customer_orders WHERE order_details = "Second time"
Tell me the number of orders with "Second time" as order detail.
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
(5,)
customers_and_addresses
SELECT t1.customer_name , t2.order_date FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id WHERE order_status = "Delivered"
Find the customer name and date of the orders that have the status "Delivered".
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Prof. Reyes Berge II', '2018-03-04 07:16:22') ('Clifford Pagac', '2018-03-08 15:30:24') ('Kitty Padberg III', '2018-03-16 03:16:57') ('Prof. Alexzander Hamill', '2018-03-22 14:57:30') ('Kitty Padberg III', '2018-03-06 12:31:35')
customers_and_addresses
SELECT t1.customer_name , t2.order_date FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id WHERE order_status = "Delivered"
What are the customer name and date of the orders whose status is "Delivered".
PRAGMA foreign_keys = ON; CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); INSERT INTO Addresses (`address_id`, `address_conten...
('Prof. Reyes Berge II', '2018-03-04 07:16:22') ('Clifford Pagac', '2018-03-08 15:30:24') ('Kitty Padberg III', '2018-03-16 03:16:57') ('Prof. Alexzander Hamill', '2018-03-22 14:57:30') ('Kitty Padberg III', '2018-03-06 12:31:35')