db_id stringclasses 146
values | question stringlengths 3 224 | sql stringlengths 18 577 | database_schema stringclasses 146
values |
|---|---|---|---|
network_2 | How many females does this network has? | SELECT count(*) FROM Person WHERE gender = 'female' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | How many females are in the network? | SELECT count(*) FROM Person WHERE gender = 'female' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the average age for all person? | SELECT avg(age) FROM Person | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the average age for all people in the table? | SELECT avg(age) FROM Person | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | How many different cities are they from? | SELECT count(DISTINCT city) FROM Person | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | How many different cities do people originate from? | SELECT count(DISTINCT city) FROM Person | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | How many type of jobs do they have? | SELECT count(DISTINCT job) FROM Person | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | How many different jobs are listed? | SELECT count(DISTINCT job) FROM Person | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Who is the oldest person? | SELECT name FROM Person WHERE age = (SELECT max(age) FROM person) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the name of the person who is the oldest? | SELECT name FROM Person WHERE age = (SELECT max(age) FROM person) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Who is the oldest person whose job is student? | SELECT name FROM Person WHERE job = 'student' AND age = (SELECT max(age) FROM person WHERE job = 'student' ) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the name of the oldest student? | SELECT name FROM Person WHERE job = 'student' AND age = (SELECT max(age) FROM person WHERE job = 'student' ) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Who is the youngest male? | SELECT name FROM Person WHERE gender = 'male' AND age = (SELECT min(age) FROM person WHERE gender = 'male' ) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the name of the youngest male? | SELECT name FROM Person WHERE gender = 'male' AND age = (SELECT min(age) FROM person WHERE gender = 'male' ) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | How old is the doctor named Zach? | SELECT age FROM Person WHERE job = 'doctor' AND name = 'Zach' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the age of the doctor named Zach? | SELECT age FROM Person WHERE job = 'doctor' AND name = 'Zach' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Who is the person whose age is below 30? | SELECT name FROM Person WHERE age < 30 | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the name of the person whose age is below 30? | SELECT name FROM Person WHERE age < 30 | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | How many people whose age is greater 30 and job is engineer? | SELECT count(*) FROM Person WHERE age > 30 AND job = 'engineer' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | HOw many engineers are older than 30? | SELECT count(*) FROM Person WHERE age > 30 AND job = 'engineer' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the average age for each gender? | SELECT avg(age) , gender FROM Person GROUP BY gender | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | How old is each gender, on average? | SELECT avg(age) , gender FROM Person GROUP BY gender | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is average age for different job title? | SELECT avg(age) , job FROM Person GROUP BY job | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | How old is the average person for each job? | SELECT avg(age) , job FROM Person GROUP BY job | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is average age of male for different job title? | SELECT avg(age) , job FROM Person WHERE gender = 'male' GROUP BY job | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the average age for a male in each job? | SELECT avg(age) , job FROM Person WHERE gender = 'male' GROUP BY job | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is minimum age for different job title? | SELECT min(age) , job FROM Person GROUP BY job | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | How old is the youngest person for each job? | SELECT min(age) , job FROM Person GROUP BY job | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the number of people who is under 40 for each gender. | SELECT count(*) , gender FROM Person WHERE age < 40 GROUP BY gender | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | How many people are under 40 for each gender? | SELECT count(*) , gender FROM Person WHERE age < 40 GROUP BY gender | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the name of people whose age is greater than any engineer sorted by their age. | SELECT name FROM Person WHERE age > (SELECT min(age) FROM person WHERE job = 'engineer') ORDER BY age | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the name of all the people who are older than at least one engineer? Order them by age. | SELECT name FROM Person WHERE age > (SELECT min(age) FROM person WHERE job = 'engineer') ORDER BY age | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the number of people whose age is greater than all engineers. | SELECT count(*) FROM Person WHERE age > (SELECT max(age) FROM person WHERE job = 'engineer') | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | How many people are older than every engineer? | SELECT count(*) FROM Person WHERE age > (SELECT max(age) FROM person WHERE job = 'engineer') | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | list the name, job title of all people ordered by their names. | SELECT name , job FROM Person ORDER BY name | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names and job titles of every person ordered alphabetically by name? | SELECT name , job FROM Person ORDER BY name | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the names of all person sorted in the descending order using age. | SELECT name FROM Person ORDER BY age DESC | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names of everybody sorted by age in descending order? | SELECT name FROM Person ORDER BY age DESC | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the name and age of all males in order of their age. | SELECT name FROM Person WHERE gender = 'male' ORDER BY age | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the name and age of every male? Order the results by age. | SELECT name FROM Person WHERE gender = 'male' ORDER BY age | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the name and age of the person who is a friend of both Dan and Alice. | SELECT T1.name , T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Dan' INTERSECT SELECT T1.name , T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Alice' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names and ages of every person who is a friend of both Dan and Alice? | SELECT T1.name , T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Dan' INTERSECT SELECT T1.name , T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Alice' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the name and age of the person who is a friend of Dan or Alice. | SELECT DISTINCT T1.name , T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Dan' OR T2.friend = 'Alice' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the different names and ages of every friend of either Dan or alice? | SELECT DISTINCT T1.name , T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Dan' OR T2.friend = 'Alice' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the name of the person who has friends with age above 40 and under age 30? | SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age > 40) INTERSECT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age < 30) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names of every person who has a friend over 40 and under 30? | SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age > 40) INTERSECT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age < 30) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the name of the person who has friends with age above 40 but not under age 30? | SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age > 40) EXCEPT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age < 30) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names of the people who are older 40 but no friends under age 30? | SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age > 40) EXCEPT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age < 30) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the name of the person who has no student friends. | SELECT name FROM person EXCEPT SELECT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.job = 'student' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names of the people who have no friends who are students? | SELECT name FROM person EXCEPT SELECT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.job = 'student' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the person who has exactly one friend. | SELECT name FROM PersonFriend GROUP BY name HAVING count(*) = 1 | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names of everybody who has exactly one friend? | SELECT name FROM PersonFriend GROUP BY name HAVING count(*) = 1 | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Who are the friends of Bob? | SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T1.name = 'Bob' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Who are Bob's friends? | SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T1.name = 'Bob' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the name of persons who are friends with Bob. | SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Bob' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names of all of Bob's friends? | SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Bob' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the names of females who are friends with Zach | SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Zach' AND T1.gender = 'female' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names of all females who are friends with Zach? | SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Zach' AND T1.gender = 'female' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the female friends of Alice. | SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Alice' AND T1.gender = 'female' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are all the friends of Alice who are female? | SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Alice' AND T1.gender = 'female' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the male friend of Alice whose job is a doctor? | SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Alice' AND T1.gender = 'male' AND T1.job = 'doctor' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Who are the friends of Alice that are doctors? | SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Alice' AND T1.gender = 'male' AND T1.job = 'doctor' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Who has a friend that is from new york city? | SELECT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.city = 'new york city' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names of all friends who are from New York? | SELECT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.city = 'new york city' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Who has friends that are younger than the average age? | SELECT DISTINCT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.age < (SELECT avg(age) FROM person) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the different names of friends who are younger than the average age for a friend? | SELECT DISTINCT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.age < (SELECT avg(age) FROM person) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Who has friends that are older than the average age? Print their friends and their ages as well | SELECT DISTINCT T2.name , T2.friend , T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.age > (SELECT avg(age) FROM person) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Whare the names, friends, and ages of all people who are older than the average age of a person? | SELECT DISTINCT T2.name , T2.friend , T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.age > (SELECT avg(age) FROM person) | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Who is the friend of Zach with longest year relationship? | SELECT friend FROM PersonFriend WHERE name = 'Zach' AND YEAR = (SELECT max(YEAR) FROM PersonFriend WHERE name = 'Zach') | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Which friend of Zach has the longest-lasting friendship? | SELECT friend FROM PersonFriend WHERE name = 'Zach' AND YEAR = (SELECT max(YEAR) FROM PersonFriend WHERE name = 'Zach') | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the age of the friend of Zach with longest year relationship? | SELECT T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Zach' AND T2.year = (SELECT max(YEAR) FROM PersonFriend WHERE name = 'Zach') | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the ages of all of Zach's friends who are in the longest relationship? | SELECT T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Zach' AND T2.year = (SELECT max(YEAR) FROM PersonFriend WHERE name = 'Zach') | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the name of persons who are friends with Alice for the shortest years. | SELECT name FROM PersonFriend WHERE friend = 'Alice' AND YEAR = (SELECT min(YEAR) FROM PersonFriend WHERE friend = 'Alice') | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names of all people who are friends with Alice for the shortest amount of time? | SELECT name FROM PersonFriend WHERE friend = 'Alice' AND YEAR = (SELECT min(YEAR) FROM PersonFriend WHERE friend = 'Alice') | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find the name, age, and job title of persons who are friends with Alice for the longest years. | SELECT T1.name , T1.age , T1.job FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Alice' AND T2.year = (SELECT max(YEAR) FROM PersonFriend WHERE friend = 'Alice') | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names, ages, and jobs of all people who are friends with Alice for the longest amount of time? | SELECT T1.name , T1.age , T1.job FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Alice' AND T2.year = (SELECT max(YEAR) FROM PersonFriend WHERE friend = 'Alice') | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Who is the person that has no friend? | SELECT name FROM person EXCEPT SELECT name FROM PersonFriend | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names of all people who do not have friends? | SELECT name FROM person EXCEPT SELECT name FROM PersonFriend | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Which person whose friends have the oldest average age? | SELECT T2.name , avg(T1.age) FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend GROUP BY T2.name ORDER BY avg(T1.age) DESC LIMIT 1 | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the name of the person who has the oldest average age for their friends, and what is that average age? | SELECT T2.name , avg(T1.age) FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend GROUP BY T2.name ORDER BY avg(T1.age) DESC LIMIT 1 | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the total number of people who has no friend living in the city of Austin. | SELECT count(DISTINCT name) FROM PersonFriend WHERE friend NOT IN (SELECT name FROM person WHERE city = 'Austin') | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What is the total number of people who have no friends living in Austin? | SELECT count(DISTINCT name) FROM PersonFriend WHERE friend NOT IN (SELECT name FROM person WHERE city = 'Austin') | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | Find Alice's friends of friends. | SELECT DISTINCT T4.name FROM PersonFriend AS T1 JOIN Person AS T2 ON T1.name = T2.name JOIN PersonFriend AS T3 ON T1.friend = T3.name JOIN PersonFriend AS T4 ON T3.friend = T4.name WHERE T2.name = 'Alice' AND T4.name != 'Alice' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
network_2 | What are the names of all of Alice's friends of friends? | SELECT DISTINCT T4.name FROM PersonFriend AS T1 JOIN Person AS T2 ON T1.name = T2.name JOIN PersonFriend AS T3 ON T1.friend = T3.name JOIN PersonFriend AS T4 ON T3.friend = T4.name WHERE T2.name = 'Alice' AND T4.name != 'Alice' | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
)
3 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
Zach 45 austin male doctor
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
)
3 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
Bob Zach 5
|
decoration_competition | How many members are there? | SELECT count(*) FROM member | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | List the names of members in ascending alphabetical order. | SELECT Name FROM member ORDER BY Name ASC | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | What are the names and countries of members? | SELECT Name , Country FROM member | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | Show the names of members whose country is "United States" or "Canada". | SELECT Name FROM member WHERE Country = "United States" OR Country = "Canada" | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | Show the different countries and the number of members from each. | SELECT Country , COUNT(*) FROM member GROUP BY Country | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | Show the most common country across members. | SELECT Country FROM member GROUP BY Country ORDER BY COUNT(*) DESC LIMIT 1 | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | Which countries have more than two members? | SELECT Country FROM member GROUP BY Country HAVING COUNT(*) > 2 | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | Show the leader names and locations of colleges. | SELECT Leader_Name , College_Location FROM college | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | Show the names of members and names of colleges they go to. | SELECT T2.Name , T1.Name FROM college AS T1 JOIN member AS T2 ON T1.College_ID = T2.College_ID | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | Show the names of members and the locations of colleges they go to in ascending alphabetical order of member names. | SELECT T2.Name , T1.College_Location FROM college AS T1 JOIN member AS T2 ON T1.College_ID = T2.College_ID ORDER BY T2.Name ASC | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | Show the distinct leader names of colleges associated with members from country "Canada". | SELECT DISTINCT T1.Leader_Name FROM college AS T1 JOIN member AS T2 ON T1.College_ID = T2.College_ID WHERE T2.Country = "Canada" | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | Show the names of members and the decoration themes they have. | SELECT T1.Name , T2.Decoration_Theme FROM member AS T1 JOIN round AS T2 ON T1.Member_ID = T2.Member_ID | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | Show the names of members that have a rank in round higher than 3. | SELECT T1.Name FROM member AS T1 JOIN round AS T2 ON T1.Member_ID = T2.Member_ID WHERE T2.Rank_in_Round > 3 | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | Show the names of members in ascending order of their rank in rounds. | SELECT T1.Name FROM member AS T1 JOIN round AS T2 ON T1.Member_ID = T2.Member_ID ORDER BY Rank_in_Round ASC | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
decoration_competition | List the names of members who did not participate in any round. | SELECT Name FROM member WHERE Member_ID NOT IN (SELECT Member_ID FROM round) | CREATE TABLE "college" (
"College_ID" int,
"Name" text,
"Leader_Name" text,
"College_Location" text,
PRIMARY KEY ("College_ID")
)
3 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
3 Calgary School Andre Arlain St. Francis Xavier
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Country" text,
"College_ID" int,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY ("College_ID") REFERENCES `college`("College_ID")
)
3 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
3 Arnold Palmer Canada 4
CREATE TABLE "round" (
"Round_ID" int,
"Member_ID" int,
"Decoration_Theme" text,
"Rank_in_Round" int,
PRIMARY KEY ("Member_ID","Round_ID"),
FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID")
)
3 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
1 10 Dark Nights 4
|
document_management | Find the name and access counts of all documents, in alphabetic order of the document name. | SELECT document_name , access_count FROM documents ORDER BY document_name | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
)
3 rows from Roles table:
role_code role_description
DBA Database Administrator
PROJ-MGR Project Manager
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
)
3 rows from Users table:
user_id role_code user_name user_login password
1 PROJ-MGR dickens.elta 0 e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2 DBA tremblay.raheem 1 9bc25a040d5647ced5ec32e1a455e90fafc10bcb
3 DBA lynn.haley 0 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
)
3 rows from Document_Structures table:
document_structure_code parent_document_structure_code document_structure_description
1 1 Header
6 1 Main section
8 1 Bib
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
)
3 rows from Functional_Areas table:
functional_area_code parent_functional_area_code functional_area_description
8 8 Signature
1 8 Acknowledgement
9 8 Keep blank
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
)
3 rows from Images table:
image_id image_alt_text image_name image_url
1 Lea top1 http://www.rempelnader.com/1.jpg
2 Arden top2 http://connellykertzmann.org/1.jpg
3 Mohamed top3 http://www.bernierconnelly.com/1.jpg
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
)
3 rows from Documents table:
document_code document_structure_code document_type_code access_count document_name
217 8 Book 1864 Learning English
621 1 Paper 8208 Research about Art history
958 8 Book 3769 Learning Database
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
)
3 rows from Document_Functional_Areas table:
document_code functional_area_code
675 9
930 1
217 1
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
)
3 rows from Document_Sections table:
section_id document_code section_sequence section_code section_title
12 714 6072 70 after
15 217 4510 14 after
19 675 7236 90 after
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
)
3 rows from Document_Sections_Images table:
section_id image_id
93 6
86 2
27 3
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.