lianghsun/spider-text2sql-bench huggingface dataset:
### Database Schema
CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)

CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)

CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)

CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

### Question
Show the residences that have at least two players.

### SQL
SELECT Residence FROM player GROUP BY Residence HAVING COUNT(*)  >=  2
### Database Schema
CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)

CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)

CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)

CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

### Question
Show the names of players and names of their coaches.

### SQL
SELECT T3.Player_name ,  T2.coach_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID  =  T2.Coach_ID JOIN player AS T3 ON T1.Player_ID  =  T3.Player_ID
### Database Schema
CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)

CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)

CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)

CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

### Question
Show the names of players coached by the rank 1 coach.

### SQL
SELECT T3.Player_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID  =  T2.Coach_ID JOIN player AS T3 ON T1.Player_ID  =  T3.Player_ID WHERE T2.Rank  =  1
### Database Schema
CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)

CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)

CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)

CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

### Question
Show the names and genders of players with a coach starting after 2011.

### SQL
SELECT T3.Player_name ,  T3.gender FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID  =  T2.Coach_ID JOIN player AS T3 ON T1.Player_ID  =  T3.Player_ID WHERE T1.Starting_year  >  2011
### Database Schema
CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)

CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)

CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)

CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

### Question
Show the names of players and names of their coaches in descending order of the votes of players.

### SQL
SELECT T3.Player_name ,  T2.coach_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID  =  T2.Coach_ID JOIN player AS T3 ON T1.Player_ID  =  T3.Player_ID ORDER BY T3.Votes DESC
### Database Schema
CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)

CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)

CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)

CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

### Question
List the names of players that do not have coaches.

### SQL
SELECT Player_name FROM player WHERE Player_ID NOT IN (SELECT Player_ID FROM player_coach)
### Database Schema
CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)

CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)

CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)

CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

### Question
Show the residences that have both a player of gender "M" and a player of gender "F".

### SQL
SELECT Residence FROM player WHERE gender  =  "M" INTERSECT SELECT Residence FROM player WHERE gender  =  "F"
### Database Schema
CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)

CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)

CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)

CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

### Question
How many coaches does each club has? List the club id, name and the number of coaches.

### SQL
SELECT T1.club_id ,  T1.club_name, count(*) FROM club AS T1 JOIN coach AS T2 ON T1.club_id  =  T2.club_id GROUP BY T1.club_id
### Database Schema
CREATE TABLE "player" (
"Player_ID" int,
"Sponsor_name" text,
"Player_name" text,
"Gender" text,
"Residence" text,
"Occupation" text,
"Votes" int,
"Rank" text,
PRIMARY KEY ("Player_ID")
)

CREATE TABLE "club" (
"Club_ID" int,
"Club_name" text,
"Region" text,
"Start_year" int,
PRIMARY KEY ("Club_ID")
)

CREATE TABLE "coach" (
"Coach_ID" int,
"Coach_name" text,
"Gender" text,
"Club_ID" int,
"Rank" int,
PRIMARY KEY ("Coach_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

CREATE TABLE "player_coach" (
"Player_ID" int,
"Coach_ID" int,
"Starting_year" int,
PRIMARY KEY ("Player_ID","Coach_ID"),
FOREIGN KEY (`Player_ID`) REFERENCES `player`(`Player_ID`),
FOREIGN KEY (`Coach_ID`) REFERENCES `coach`(`Coach_ID`)
)

CREATE TABLE "match_result" (
"Rank" int,
"Club_ID" int,
"Gold" int,
"Big_Silver" int,
"Small_Silver" int,
"Bronze" int,
"Points" int,
PRIMARY KEY ("Rank","Club_ID"),
FOREIGN KEY (`Club_ID`) REFERENCES `club`(`Club_ID`)
)

### Question
How many gold medals has the club with the most coaches won?

### SQL
SELECT T1.club_id ,  T1.gold FROM match_result AS T1 JOIN coach AS T2 ON T1.club_id  =  T2.club_id GROUP BY T1.club_id ORDER BY count(*) DESC LIMIT 1
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
How many gymnasts are there?

### SQL
SELECT count(*) FROM gymnast
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Count the number of gymnasts.

### SQL
SELECT count(*) FROM gymnast
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
List the total points of gymnasts in descending order.

### SQL
SELECT Total_Points FROM gymnast ORDER BY Total_Points DESC
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What are the total points for all gymnasts, ordered by total points descending?

### SQL
SELECT Total_Points FROM gymnast ORDER BY Total_Points DESC
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
List the total points of gymnasts in descending order of floor exercise points.

### SQL
SELECT Total_Points FROM gymnast ORDER BY Floor_Exercise_Points DESC
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What are the total points of gymnasts, ordered by their floor exercise points descending?

### SQL
SELECT Total_Points FROM gymnast ORDER BY Floor_Exercise_Points DESC
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What is the average horizontal bar points for all gymnasts?

### SQL
SELECT avg(Horizontal_Bar_Points) FROM gymnast
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Return the average horizontal bar points across all gymnasts.

### SQL
SELECT avg(Horizontal_Bar_Points) FROM gymnast
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What are the names of people in ascending alphabetical order?

### SQL
SELECT Name FROM People ORDER BY Name ASC
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Return the names of people, ordered alphabetically.

### SQL
SELECT Name FROM People ORDER BY Name ASC
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What are the names of gymnasts?

### SQL
SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Return the names of the gymnasts.

### SQL
SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What are the names of gymnasts whose hometown is not "Santo Domingo"?

### SQL
SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID WHERE T2.Hometown != "Santo Domingo"
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Return the names of gymnasts who did not grow up in Santo Domingo.

### SQL
SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID WHERE T2.Hometown != "Santo Domingo"
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What is the age of the tallest person?

### SQL
SELECT Age FROM people ORDER BY Height DESC LIMIT 1
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Return the age of the person with the greatest height.

### SQL
SELECT Age FROM people ORDER BY Height DESC LIMIT 1
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
List the names of the top 5 oldest people.

### SQL
SELECT Name FROM People ORDER BY Age DESC LIMIT 5
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What are the names of the five oldest people?

### SQL
SELECT Name FROM People ORDER BY Age DESC LIMIT 5
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What is the total point count of the youngest gymnast?

### SQL
SELECT T1.Total_Points FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID ORDER BY T2.Age ASC LIMIT 1
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Return the total points of the gymnast with the lowest age.

### SQL
SELECT T1.Total_Points FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID ORDER BY T2.Age ASC LIMIT 1
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What is the average age of all gymnasts?

### SQL
SELECT avg(T2.Age) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Return the average age across all gymnasts.

### SQL
SELECT avg(T2.Age) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What are the distinct hometowns of gymnasts with total points more than 57.5?

### SQL
SELECT DISTINCT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID WHERE T1.Total_Points  >  57.5
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Give the different hometowns of gymnasts that have a total point score of above 57.5.

### SQL
SELECT DISTINCT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID WHERE T1.Total_Points  >  57.5
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What are the hometowns of gymnasts and the corresponding number of gymnasts?

### SQL
SELECT T2.Hometown ,  COUNT(*) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID GROUP BY T2.Hometown
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
How many gymnasts are from each hometown?

### SQL
SELECT T2.Hometown ,  COUNT(*) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID GROUP BY T2.Hometown
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What is the most common hometown of gymnasts?

### SQL
SELECT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID GROUP BY T2.Hometown ORDER BY COUNT(*) DESC LIMIT 1
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Return the hometown that is most common among gymnasts.

### SQL
SELECT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID GROUP BY T2.Hometown ORDER BY COUNT(*) DESC LIMIT 1
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What are the hometowns that are shared by at least two gymnasts?

### SQL
SELECT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID GROUP BY T2.Hometown HAVING COUNT(*)  >=  2
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Give the hometowns from which two or more gymnasts are from.

### SQL
SELECT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID GROUP BY T2.Hometown HAVING COUNT(*)  >=  2
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
List the names of gymnasts in ascending order by their heights.

### SQL
SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID ORDER BY T2.Height ASC
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What are the names of gymnasts, ordered by their heights ascending?

### SQL
SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID ORDER BY T2.Height ASC
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
List the distinct hometowns that are not associated with any gymnast.

### SQL
SELECT DISTINCT Hometown FROM people EXCEPT SELECT DISTINCT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
From which hometowns did no gymnasts come from?

### SQL
SELECT DISTINCT Hometown FROM people EXCEPT SELECT DISTINCT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Show the hometowns shared by people older than 23 and younger than 20.

### SQL
SELECT Hometown FROM people WHERE Age  >  23 INTERSECT SELECT Hometown FROM people WHERE Age  <  20
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
From which hometowns did both people older than 23 and younger than 20 come from?

### SQL
SELECT Hometown FROM people WHERE Age  >  23 INTERSECT SELECT Hometown FROM people WHERE Age  <  20
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
How many distinct hometowns did these people have?

### SQL
SELECT count(DISTINCT Hometown) FROM people
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Count the number of different hometowns of these people.

### SQL
SELECT count(DISTINCT Hometown) FROM people
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
Show the ages of gymnasts in descending order of total points.

### SQL
SELECT T2.Age FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID ORDER BY T1.Total_Points DESC
### Database Schema
CREATE TABLE "gymnast" (
"Gymnast_ID" int,
"Floor_Exercise_Points" real,
"Pommel_Horse_Points" real,
"Rings_Points" real,
"Vault_Points" real,
"Parallel_Bars_Points" real,
"Horizontal_Bar_Points" real,
"Total_Points" real,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY ("Gymnast_ID") REFERENCES "people"("People_ID")
)

CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Age" real,
"Height" real,
"Hometown" text,
PRIMARY KEY ("People_ID")
)

### Question
What are the ages of the gymnasts, ordered descending by their total points?

### SQL
SELECT T2.Age FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID  =  T2.People_ID ORDER BY T1.Total_Points DESC
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
Find the total savings balance of all accounts except the account with name ‘Brown’.

### SQL
SELECT sum(T2.balance) FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid WHERE T1.name != 'Brown'
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
What is the total balance of savings accounts not belonging to someone with the name Brown?

### SQL
SELECT sum(T2.balance) FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid WHERE T1.name != 'Brown'
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
How many accounts are there in total?

### SQL
SELECT count(*) FROM accounts
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
Count the number of accounts.

### SQL
SELECT count(*) FROM accounts
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
What is the total checking balance in all accounts?

### SQL
SELECT sum(balance) FROM checking
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
Find the total balance across checking accounts.

### SQL
SELECT sum(balance) FROM checking
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
Find the average checking balance.

### SQL
SELECT avg(balance) FROM checking
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
What is the average balance in checking accounts?

### SQL
SELECT avg(balance) FROM checking
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
How many accounts have a savings balance above the average savings balance?

### SQL
SELECT count(*) FROM savings WHERE balance  >  (SELECT avg(balance) FROM savings)
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
Find the number of accounts with a savings balance that is higher than the average savings balance.

### SQL
SELECT count(*) FROM savings WHERE balance  >  (SELECT avg(balance) FROM savings)
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
Find the name and id of accounts whose checking balance is below the maximum checking balance.

### SQL
SELECT T1.custid ,  T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid WHERE T2.balance  <  (SELECT max(balance) FROM checking)
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
What are the customer id and name corresponding to accounts with a checking balance less than the largest checking balance?

### SQL
SELECT T1.custid ,  T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid WHERE T2.balance  <  (SELECT max(balance) FROM checking)
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
What is the checking balance of the account whose owner’s name contains the substring ‘ee’?

### SQL
SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid WHERE T1.name LIKE '%ee%'
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
Find the balance of the checking account belonging to an owner whose name contains 'ee'.

### SQL
SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid WHERE T1.name LIKE '%ee%'
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
Find the checking balance and saving balance in the Brown’s account.

### SQL
SELECT T2.balance ,  T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid JOIN savings AS T3 ON T1.custid  =  T3.custid WHERE T1.name  =  'Brown'
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
What are the checking and savings balances in accounts belonging to Brown?

### SQL
SELECT T2.balance ,  T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid JOIN savings AS T3 ON T1.custid  =  T3.custid WHERE T1.name  =  'Brown'
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
Find the names of accounts whose checking balance is above the average checking balance, but savings balance is below the average savings balance.

### SQL
SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid WHERE T2.balance  >  (SELECT avg(balance) FROM checking) INTERSECT SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid WHERE T2.balance  <  (SELECT avg(balance) FROM savings)
### Database Schema
CREATE TABLE ACCOUNTS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    name        VARCHAR(64) NOT NULL
)

CREATE TABLE SAVINGS (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

CREATE TABLE CHECKING (
    custid      BIGINT      NOT NULL PRIMARY KEY,
    balance        FLOAT       NOT NULL,
    FOREIGN KEY (custid) REFERENCES ACCOUNTS (custid)
)

### Question
What are the names of accounts with checking balances greater than the average checking balance and savings balances below the average savings balance?

### SQL
SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid WHERE T2.balance  >  (SELECT avg(balance) FROM checking) INTERSECT SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid WHERE T2.balance  <  (SELECT avg(balance) FROM savings)