db_name
stringclasses 146
values | prompt
stringlengths 310
4.81k
|
|---|---|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# How many different types of sports do we offer?
#
### SQL:
#
# SELECT count(DISTINCT sportname) FROM Sportsinfo
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# How many students play sports?
#
### SQL:
#
# SELECT count(DISTINCT StuID) FROM Sportsinfo
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# How many different students are involved in sports?
#
### SQL:
#
# SELECT count(DISTINCT StuID) FROM Sportsinfo
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# List ids for all student who are on scholarship.
#
### SQL:
#
# SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y'
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the ids for all sporty students who are on scholarship?
#
### SQL:
#
# SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y'
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show last names for all student who are on scholarship.
#
### SQL:
#
# SELECT T2.Lname FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T1.onscholarship = 'Y'
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the last names for all scholarship students?
#
### SQL:
#
# SELECT T2.Lname FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T1.onscholarship = 'Y'
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# How many games are played for all students?
#
### SQL:
#
# SELECT sum(gamesplayed) FROM Sportsinfo
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What is the total number of games played?
#
### SQL:
#
# SELECT sum(gamesplayed) FROM Sportsinfo
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# How many games are played for all football games by students on scholarship?
#
### SQL:
#
# SELECT sum(gamesplayed) FROM Sportsinfo WHERE sportname = "Football" AND onscholarship = 'Y'
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What is the total number of all football games played by scholarship students?
#
### SQL:
#
# SELECT sum(gamesplayed) FROM Sportsinfo WHERE sportname = "Football" AND onscholarship = 'Y'
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show all sport name and the number of students.
#
### SQL:
#
# SELECT sportname , count(*) FROM Sportsinfo GROUP BY sportname
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# How many students play each sport?
#
### SQL:
#
# SELECT sportname , count(*) FROM Sportsinfo GROUP BY sportname
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show all student IDs with the number of sports and total number of games played
#
### SQL:
#
# SELECT StuID , count(*) , sum(gamesplayed) FROM Sportsinfo GROUP BY StuID
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the ids of all students along with how many sports and games did they play?
#
### SQL:
#
# SELECT StuID , count(*) , sum(gamesplayed) FROM Sportsinfo GROUP BY StuID
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show all student IDs with more than total 10 hours per week on all sports played.
#
### SQL:
#
# SELECT StuID FROM Sportsinfo GROUP BY StuID HAVING sum(hoursperweek) > 10
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the student IDs for everybody who worked for more than 10 hours per week on all sports?
#
### SQL:
#
# SELECT StuID FROM Sportsinfo GROUP BY StuID HAVING sum(hoursperweek) > 10
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What is the first name and last name of the student who have most number of sports?
#
### SQL:
#
# SELECT T2.Fname , T2.Lname FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID GROUP BY T1.StuID ORDER BY count(*) DESC LIMIT 1
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What is the first and last name of the student who played the most sports?
#
### SQL:
#
# SELECT T2.Fname , T2.Lname FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID GROUP BY T1.StuID ORDER BY count(*) DESC LIMIT 1
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Which sport has most number of students on scholarship?
#
### SQL:
#
# SELECT sportname FROM Sportsinfo WHERE onscholarship = 'Y' GROUP BY sportname ORDER BY count(*) DESC LIMIT 1
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What is the sport with the most scholarship students?
#
### SQL:
#
# SELECT sportname FROM Sportsinfo WHERE onscholarship = 'Y' GROUP BY sportname ORDER BY count(*) DESC LIMIT 1
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show student ids who don't have any sports.
#
### SQL:
#
# SELECT StuID FROM Student EXCEPT SELECT StuID FROM Sportsinfo
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the ids of all students who don't play sports?
#
### SQL:
#
# SELECT StuID FROM Student EXCEPT SELECT StuID FROM Sportsinfo
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show student ids who are on scholarship and have major 600.
#
### SQL:
#
# SELECT StuID FROM Student WHERE major = 600 INTERSECT SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y'
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the student ids for those on scholarship in major number 600?
#
### SQL:
#
# SELECT StuID FROM Student WHERE major = 600 INTERSECT SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y'
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show student ids who are female and play football.
#
### SQL:
#
# SELECT StuID FROM Student WHERE sex = 'F' INTERSECT SELECT StuID FROM Sportsinfo WHERE sportname = "Football"
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the ids of all female students who play football?
#
### SQL:
#
# SELECT StuID FROM Student WHERE sex = 'F' INTERSECT SELECT StuID FROM Sportsinfo WHERE sportname = "Football"
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show all male student ids who don't play football.
#
### SQL:
#
# SELECT StuID FROM Student WHERE sex = 'M' EXCEPT SELECT StuID FROM Sportsinfo WHERE sportname = "Football"
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the ids of all male students who do not play football?
#
### SQL:
#
# SELECT StuID FROM Student WHERE sex = 'M' EXCEPT SELECT StuID FROM Sportsinfo WHERE sportname = "Football"
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show total hours per week and number of games played for student David Shieber.
#
### SQL:
#
# 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"
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What is the total number of hours per work and number of games played by David Shieber?
#
### SQL:
#
# 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"
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show total hours per week and number of games played for students under 20.
#
### SQL:
#
# SELECT sum(hoursperweek) , sum(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.age < 20
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What is the total number of hours per week and number of games played by students under 20?
#
### SQL:
#
# SELECT sum(hoursperweek) , sum(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.age < 20
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# How many students play video games?
#
### SQL:
#
# SELECT count(DISTINCT StuID) FROM Plays_games
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# How many different students play games?
#
### SQL:
#
# SELECT count(DISTINCT StuID) FROM Plays_games
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show ids of students who don't play video game.
#
### SQL:
#
# SELECT StuID FROM Student EXCEPT SELECT StuID FROM Plays_games
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the ids of all students who are not video game players?
#
### SQL:
#
# SELECT StuID FROM Student EXCEPT SELECT StuID FROM Plays_games
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show ids of students who play video game and play sports.
#
### SQL:
#
# SELECT StuID FROM Sportsinfo INTERSECT SELECT StuID FROM Plays_games
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the ids of all students who played video games and sports?
#
### SQL:
#
# SELECT StuID FROM Sportsinfo INTERSECT SELECT StuID FROM Plays_games
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show all game ids and the number of hours played.
#
### SQL:
#
# SELECT gameid , sum(hours_played) FROM Plays_games GROUP BY gameid
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are ids and total number of hours played for each game?
#
### SQL:
#
# SELECT gameid , sum(hours_played) FROM Plays_games GROUP BY gameid
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show all student ids and the number of hours played.
#
### SQL:
#
# SELECT Stuid , sum(hours_played) FROM Plays_games GROUP BY Stuid
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the ids of all students and number of hours played?
#
### SQL:
#
# SELECT Stuid , sum(hours_played) FROM Plays_games GROUP BY Stuid
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show the game name that has most number of hours played.
#
### SQL:
#
# 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
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What is the name of the game that has been played the most?
#
### SQL:
#
# 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
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show all game names played by at least 1000 hours.
#
### SQL:
#
# 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
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the names of all the games that have been played for at least 1000 hours?
#
### SQL:
#
# 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
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Show all game names played by Linda Smith
#
### SQL:
#
# 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"
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the names of all games played by Linda Smith?
#
### SQL:
#
# 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"
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Find the last and first name of students who are playing Football or Lacrosse.
#
### SQL:
#
# 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"
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What is the first and last name of all students who play Football or Lacrosse?
#
### SQL:
#
# 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"
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Find the first name and age of the students who are playing both Football and Lacrosse.
#
### SQL:
#
# SELECT fname , age FROM Student WHERE StuID IN (SELECT StuID FROM Sportsinfo WHERE SportName = "Football" INTERSECT SELECT StuID FROM Sportsinfo WHERE SportName = "Lacrosse")
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# What are the first names and ages of all students who are playing both Football and Lacrosse?
#
### SQL:
#
# SELECT fname , age FROM Student WHERE StuID IN (SELECT StuID FROM Sportsinfo WHERE SportName = "Football" INTERSECT SELECT StuID FROM Sportsinfo WHERE SportName = "Lacrosse")
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# Find the last name and gender of the students who are playing both Call of Destiny and Works of Widenius games.
#
### SQL:
#
# 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")
#
### End.
|
game_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code )
# Video_Games ( GameID, GName, GType )
# Plays_Games ( StuID, GameID, Hours_Played )
# SportsInfo ( StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship )
#
# Plays_Games.StuID can be joined with Student.StuID
# Plays_Games.GameID can be joined with Video_Games.GameID
# SportsInfo.StuID can be joined with Student.StuID
#
### Question:
#
# what is the last name and gender of all students who played both Call of Destiny and Works of Widenius?
#
### SQL:
#
# 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")
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the name of all customers.
#
### SQL:
#
# SELECT customer_name FROM customers
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# What are the names of all the customers?
#
### SQL:
#
# SELECT customer_name FROM customers
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# How many customers are there?
#
### SQL:
#
# SELECT count(*) FROM customers
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Return the total number of distinct customers.
#
### SQL:
#
# SELECT count(*) FROM customers
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# What is the average amount of items ordered in each order?
#
### SQL:
#
# SELECT avg(order_quantity) FROM order_items
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the average order quantity per order.
#
### SQL:
#
# SELECT avg(order_quantity) FROM order_items
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# What are the names of customers who use payment method "Cash"?
#
### SQL:
#
# SELECT customer_name FROM customers WHERE payment_method = "Cash"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Which customers use "Cash" for payment method? Return the customer names.
#
### SQL:
#
# SELECT customer_name FROM customers WHERE payment_method = "Cash"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the "date became customers" of the customers whose ID is between 10 and 20.
#
### SQL:
#
# SELECT date_became_customer FROM customers WHERE customer_id BETWEEN 10 AND 20
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# What are the dates when customers with ids between 10 and 20 became customers?
#
### SQL:
#
# SELECT date_became_customer FROM customers WHERE customer_id BETWEEN 10 AND 20
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Which payment method is used by most customers?
#
### SQL:
#
# SELECT payment_method FROM customers GROUP BY payment_method ORDER BY count(*) DESC LIMIT 1
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the payment method that is used most frequently.
#
### SQL:
#
# SELECT payment_method FROM customers GROUP BY payment_method ORDER BY count(*) DESC LIMIT 1
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# What are the names of customers using the most popular payment method?
#
### SQL:
#
# SELECT customer_name FROM customers WHERE payment_method = (SELECT payment_method FROM customers GROUP BY payment_method ORDER BY count(*) DESC LIMIT 1)
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the name of the customers who use the most frequently used payment method.
#
### SQL:
#
# SELECT customer_name FROM customers WHERE payment_method = (SELECT payment_method FROM customers GROUP BY payment_method ORDER BY count(*) DESC LIMIT 1)
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# What are all the payment methods?
#
### SQL:
#
# SELECT DISTINCT payment_method FROM customers
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Return all the distinct payment methods used by customers.
#
### SQL:
#
# SELECT DISTINCT payment_method FROM customers
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# What are the details of all products?
#
### SQL:
#
# SELECT DISTINCT product_details FROM products
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Return the the details of all products.
#
### SQL:
#
# SELECT DISTINCT product_details FROM products
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the name of all customers whose name contains "Alex".
#
### SQL:
#
# SELECT customer_name FROM customers WHERE customer_name LIKE "%Alex%"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Which customer's name contains "Alex"? Find the full name.
#
### SQL:
#
# SELECT customer_name FROM customers WHERE customer_name LIKE "%Alex%"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the detail of products whose detail contains the word "Latte" or the word "Americano"
#
### SQL:
#
# SELECT product_details FROM products WHERE product_details LIKE "%Latte%" OR product_details LIKE "%Americano%"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Which product's detail contains the word "Latte" or "Americano"? Return the full detail.
#
### SQL:
#
# SELECT product_details FROM products WHERE product_details LIKE "%Latte%" OR product_details LIKE "%Americano%"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# What is the address content of the customer named "Maudie Kertzmann"?
#
### SQL:
#
# 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"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Return the address content for the customer whose name is "Maudie Kertzmann".
#
### SQL:
#
# 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"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# How many customers are living in city "Lake Geovannyton"?
#
### SQL:
#
# 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"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the number of customers who live in the city called Lake Geovannyton.
#
### SQL:
#
# 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"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the name of customers who are living in Colorado?
#
### SQL:
#
# 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"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# What are the names of customers who live in Colorado state?
#
### SQL:
#
# 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"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the list of cities that no customer is living in.
#
### SQL:
#
# 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)
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# What are the cities no customers live in?
#
### SQL:
#
# 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)
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Which city has the most customers living in?
#
### SQL:
#
# 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
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the city where the most customers live.
#
### SQL:
#
# 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
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Retrieve the list of all cities.
#
### SQL:
#
# SELECT DISTINCT city FROM addresses
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# List all the distinct cities
#
### SQL:
#
# SELECT DISTINCT city FROM addresses
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the city with post code 255.
#
### SQL:
#
# SELECT city FROM addresses WHERE zip_postcode = 255
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Which city is post code 255 located in?
#
### SQL:
#
# SELECT city FROM addresses WHERE zip_postcode = 255
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the state and country of all cities with post code starting with 4.
#
### SQL:
#
# SELECT state_province_county , country FROM addresses WHERE zip_postcode LIKE "4%"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# What are the state and country of all the cities that have post codes starting with 4.\
#
### SQL:
#
# SELECT state_province_county , country FROM addresses WHERE zip_postcode LIKE "4%"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# List the countries having more than 4 addresses listed.
#
### SQL:
#
# SELECT country FROM addresses GROUP BY country HAVING count(address_id) > 4
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# For which countries are there more than four distinct addresses listed?
#
### SQL:
#
# SELECT country FROM addresses GROUP BY country HAVING count(address_id) > 4
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# List all the contact channel codes that were used less than 5 times.
#
### SQL:
#
# SELECT channel_code FROM customer_contact_channels GROUP BY channel_code HAVING count(customer_id) < 5
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Which contact channel codes were used less than 5 times?
#
### SQL:
#
# SELECT channel_code FROM customer_contact_channels GROUP BY channel_code HAVING count(customer_id) < 5
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Which contact channel has been used by the customer with name "Tillman Ernser"?
#
### SQL:
#
# 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"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# Find the contact channel code that was used by the customer named "Tillman Ernser".
#
### SQL:
#
# 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"
#
### End.
|
customers_and_addresses
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Addresses ( address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details )
# Products ( product_id, product_details )
# Customers ( customer_id, payment_method, customer_name, date_became_customer, other_customer_details )
# Customer_Addresses ( customer_id, address_id, date_address_from, address_type, date_address_to )
# Customer_Contact_Channels ( customer_id, channel_code, active_from_date, active_to_date, contact_number )
# Customer_Orders ( order_id, customer_id, order_status, order_date, order_details )
# Order_Items ( order_id, product_id, order_quantity )
#
# Customer_Addresses.customer_id can be joined with Customers.customer_id
# Customer_Addresses.address_id can be joined with Addresses.address_id
# Customer_Contact_Channels.customer_id can be joined with Customers.customer_id
# Customer_Orders.customer_id can be joined with Customers.customer_id
# Order_Items.order_id can be joined with Customer_Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
#
### Question:
#
# What is the "active to date" of the latest contact channel used by "Tillman Ernser"?
#
### SQL:
#
# 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"
#
### End.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.