aherntech/sparc huggingface dataset:
Database: perpetrator
Question sequence:
What are the number of people injured for each perpetrator?
What are the heights of each perpetrator in descending order of the number of people they injured?
SQL query sequence:
SELECT T1.Name, T2.Injured FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID  =  T2.People_ID;
SELECT T1.Height FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID  =  T2.People_ID ORDER BY T2.Injured DESC;
Final question: What are the heights of perpetrators in descending order of the number of people they injured?
Final SQL: SELECT T1.Height FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID  =  T2.People_ID ORDER BY T2.Injured DESC;
Database: perpetrator
Question sequence:
What year corresponds with each perpetrator？
How about country?
Show each country and the corresponding number of perpetrators there.
SQL query sequence:
SELECT Year FROM perpetrator;
SELECT Country FROM perpetrator;
SELECT Country ,  COUNT(*) FROM perpetrator GROUP BY Country;
Final question: What are the countries of perpetrators? Show each country and the corresponding number of perpetrators there.
Final SQL: SELECT Country ,  COUNT(*) FROM perpetrator GROUP BY Country;
Database: perpetrator
Question sequence:
What are the countries of perpetrators? Show each country and the corresponding number of perpetrators there.
Which country has the fewest perpetrators?
How about the most?
SQL query sequence:
SELECT Country ,  COUNT(*) FROM perpetrator GROUP BY Country;
SELECT Country ,  COUNT(*) FROM perpetrator GROUP BY Country ORDER BY COUNT(*) ASC LIMIT 1;
SELECT Country ,  COUNT(*) FROM perpetrator GROUP BY Country ORDER BY COUNT(*) DESC LIMIT 1;
Final question: What is the country that has the most perpetrators?
Final SQL: SELECT Country ,  COUNT(*) FROM perpetrator GROUP BY Country ORDER BY COUNT(*) DESC LIMIT 1;
Database: perpetrator
Question sequence:
What is the country that has the most perpetrators?
Which ones have more more than 1 perpetrator?
How about those with at least two perpetrators?
SQL query sequence:
SELECT Country ,  COUNT(*) FROM perpetrator GROUP BY Country ORDER BY COUNT(*) DESC LIMIT 1;
SELECT Country ,  COUNT(*) FROM perpetrator GROUP BY Country HAVING COUNT(*)  <= 1;
SELECT Country ,  COUNT(*) FROM perpetrator GROUP BY Country HAVING COUNT(*)  >=  2;
Final question: What are the countries that have at least two perpetrators?
Final SQL: SELECT Country ,  COUNT(*) FROM perpetrator GROUP BY Country HAVING COUNT(*)  >=  2;
Database: perpetrator
Question sequence:
For each perpetrator, show the year that corresponds?
Show me their names.
Sort the result in descending order by year.
SQL query sequence:
SELECT Year FROM perpetrator;
SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID  =  T2.People_ID;
SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID  =  T2.People_ID ORDER BY T2.Year DESC;
Final question: List the names of perpetrators in descending order of the year.
Final SQL: SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID  =  T2.People_ID ORDER BY T2.Year DESC;
Database: perpetrator
Question sequence:
Show me all about people.
Which of those are perpetrators?
Show the rest of peoples' names.
SQL query sequence:
SELECT * FROM people;
SELECT Name FROM people WHERE People_ID IN (SELECT People_ID FROM perpetrator);
SELECT Name FROM people WHERE People_ID NOT IN (SELECT People_ID FROM perpetrator);
Final question: List the names of people that are not perpetrators.
Final SQL: SELECT Name FROM people WHERE People_ID NOT IN (SELECT People_ID FROM perpetrator);
Database: perpetrator
Question sequence:
For each perpetrator, show the ids and his or her country.
Also, show how many they have each injured.
Which countries have perpetrators who have injured more than 50?
Which of these also have perpetrators who have injured fewer than 20?
SQL query sequence:
SELECT Country, Perpetrator_ID FROM perpetrator;
SELECT Country, Perpetrator_ID, Injured FROM perpetrator;
SELECT Country FROM perpetrator WHERE Injured  >  50;
SELECT Country FROM perpetrator WHERE Injured  >  50 INTERSECT SELECT Country FROM perpetrator WHERE Injured  <  20;
Final question: Show the countries that have both perpetrators with injures more than 50 and perpetrators with injures smaller than 20.
Final SQL: SELECT Country FROM perpetrator WHERE Injured  >  50 INTERSECT SELECT Country FROM perpetrator WHERE Injured  <  20
Database: perpetrator
Question sequence:
Show me the location for each perpetrator.
What are the distinct locations?
How many are there in the result?
SQL query sequence:
SELECT Location FROM perpetrator;
SELECT DISTINCT LOCATION FROM perpetrator;
SELECT count(DISTINCT LOCATION) FROM perpetrator;
Final question: How many distinct locations of perpetrators are there?
Final SQL: SELECT count(DISTINCT LOCATION) FROM perpetrator;
Database: perpetrator
Question sequence:
What is the date for the perpetrator?
Who's the tallest perpetrator?
What's his date?
SQL query sequence:
SELECT Date FROM perpetrator;
SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID  =  T2.People_ID ORDER BY T1.Height DESC LIMIT 1
SELECT T2.Date FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID  =  T2.People_ID ORDER BY T1.Height DESC LIMIT 1
Final question: Show the date of the tallest perpetrator.
Final SQL: SELECT T2.Date FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID  =  T2.People_ID ORDER BY T1.Height DESC LIMIT 1
Database: company_1
Question sequence:
how many departments are there?
show all their info.
where are they each located?
what are the names of departments that are located in Houston?
SQL query sequence:
SELECT COUNT(*) FROM department
SELECT * FROM department
SELECT Dlocation FROM department AS t1 JOIN dept_locations AS t2 ON t1.dnumber  =  t2.dnumber
SELECT t1.dname FROM department AS t1 JOIN dept_locations AS t2 ON t1.dnumber  =  t2.dnumber WHERE t2.dlocation  =  'Houston'
Final question: Find the names of departments that are located in Houston.
Final SQL: SELECT t1.dname FROM department AS t1 JOIN dept_locations AS t2 ON t1.dnumber  =  t2.dnumber WHERE t2.dlocation  =  'Houston'
Database: ship_1
Question sequence:
What are the captains names and ages?
What is the average age for each rank?
Per rank, how many are older than 50?
SQL query sequence:
SELECT name, age from captain
SELECT rank, avg(age) from captain GROUP by rank
SELECT count(*) ,  rank FROM captain WHERE age  <  50 GROUP BY rank
Final question: How many captains younger than 50 are in each rank?
Final SQL: SELECT count(*) ,  rank FROM captain WHERE age  <  50 GROUP BY rank
Database: ship_1
Question sequence:
What are the names and ranks of captains?
Which rank is most common?
SQL query sequence:
SELECT name, rank from captain
SELECT rank FROM captain GROUP BY rank ORDER BY count(*) DESC LIMIT 1
Final question: Which rank is the most common among captains?
Final SQL: SELECT rank FROM captain GROUP BY rank ORDER BY count(*) DESC LIMIT 1
Database: ship_1
Question sequence:
Give the classes of captains.
Group by class and count.
Which class has more than two?
SQL query sequence:
SELECT Class from captain
SELECT Class, count(*) from captain Group by class
SELECT CLASS FROM captain GROUP BY CLASS HAVING count(*)  >  2
Final question: Which classes have more than two captains?
Final SQL: SELECT CLASS FROM captain GROUP BY CLASS HAVING count(*)  >  2
Database: ship_1
Question sequence:
How many captains are either Midshipman or Lieutenant?
What are their names?
SQL query sequence:
SELECT count(*) FROM captain WHERE rank  =  'Midshipman' OR rank  =  'Lieutenant'
SELECT name FROM captain WHERE rank  =  'Midshipman' OR rank  =  'Lieutenant'
Final question: Find the name of captains whose rank are either Midshipman or Lieutenant.
Final SQL: SELECT name FROM captain WHERE rank  =  'Midshipman' OR rank  =  'Lieutenant'
Database: ship_1
Question sequence:
Order class by increasing age. Also show age.
What are the average and minimum age of captains in different class?
SQL query sequence:
SELECT class, age from captain Order by age
SELECT avg(age) ,  min(age) ,  CLASS FROM captain GROUP BY CLASS
Final question: What are the average and minimum age of captains in different class?
Final SQL: SELECT avg(age) ,  min(age) ,  CLASS FROM captain GROUP BY CLASS
Database: ship_1
Question sequence:
Which ranks of captains are in the Cutter class?
How about Armed schooner?
Intersect those.
SQL query sequence:
SELECT DISTINCT rank FROM captain WHERE CLASS  =  'Cutter'
SELECT rank FROM captain WHERE CLASS  =  'Armed schooner'
SELECT rank FROM captain WHERE CLASS  =  'Cutter' INTERSECT SELECT rank FROM captain WHERE CLASS  =  'Armed schooner'
Final question: Find the captain rank that has some captains in both Cutter and Armed schooner classes.
Final SQL: SELECT rank FROM captain WHERE CLASS  =  'Cutter' INTERSECT SELECT rank FROM captain WHERE CLASS  =  'Armed schooner'
Database: ship_1
Question sequence:
For each class, what are the ranks?
Find the captain rank that has no captain in Third-rate ship of the line class.
SQL query sequence:
SELECT DISTINCT class, rank from captain Order by class
SELECT rank FROM captain EXCEPT SELECT rank FROM captain WHERE CLASS  =  'Third-rate ship of the line'
Final question: Find the captain rank that has no captain in Third-rate ship of the line class.
Final SQL: SELECT rank FROM captain EXCEPT SELECT rank FROM captain WHERE CLASS  =  'Third-rate ship of the line'
Database: ship_1
Question sequence:
Sort captains records by age.
Just their names.
limit it to the one youngest.
SQL query sequence:
SELECT * from captain order by age
SELECT name from captain order by age
SELECT name FROM captain ORDER BY age LIMIT 1
Final question: What is the name of the youngest captain?
Final SQL: SELECT name FROM captain ORDER BY age LIMIT 1
Database: ship_1
Question sequence:
What is the most recent build year?
Which ships were built in the most recent year?
Also give the type and flag.
SQL query sequence:
SELECT max(built_year) from ship
SELECT name from ship where built_year in (SELECT max(built_year) from ship)
SELECT name, type, flag from ship where built_year in (SELECT max(built_year) from ship)
Final question: Find the name, type, and flag of the ships that were built in the most recent year.
Final SQL: SELECT name, type, flag from ship where built_year in (SELECT max(built_year) from ship)
Database: ship_1
Question sequence:
Which flags are used?
Which is most common?
SQL query sequence:
SELECT DISTINCT flag from ship
SELECT flag FROM ship GROUP BY flag ORDER BY count(*) DESC LIMIT 1
Final question: Which flag is most widely used among all ships?
Final SQL: SELECT flag FROM ship GROUP BY flag ORDER BY count(*) DESC LIMIT 1
Database: ship_1
Question sequence:
Which type of ship has flag Panama?
How about Malta?
Which types have ships with both flags?
SQL query sequence:
SELECT DISTINCT TYPE FROM ship WHERE flag  =  'Panama'
SELECT TYPE FROM ship WHERE flag  =  'Malta'
SELECT TYPE FROM ship WHERE flag  =  'Panama' INTERSECT SELECT TYPE FROM ship WHERE flag  =  'Malta'
Final question: Find the ship type that are used by both ships with Panama and Malta flags.
Final SQL: SELECT TYPE FROM ship WHERE flag  =  'Panama' INTERSECT SELECT TYPE FROM ship WHERE flag  =  'Malta'
Database: ship_1
Question sequence:
What are the distinct build years of ships?
Which is more common?
SQL query sequence:
SELECT DISTINCT built_year from ship
SELECT built_year FROM ship GROUP BY built_year ORDER BY count(*) DESC LIMIT 1
Final question: In which year were most of ships built?
Final SQL: SELECT built_year FROM ship GROUP BY built_year ORDER BY count(*) DESC LIMIT 1
Database: ship_1
Question sequence:
List each ship with its captains.
Which ship has more than one captain?
SQL query sequence:
SELECT t1.name, t2.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id  =  t2.ship_id
SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id  =  t2.ship_id GROUP BY t2.ship_id HAVING count(*)  >  1
Final question: Find the name of the ships that have more than one captain.
Final SQL: SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id  =  t2.ship_id GROUP BY t2.ship_id HAVING count(*)  >  1
Database: ship_1
Question sequence:
Which ship ids are not in the captain records?
Give their names and classes
SQL query sequence:
SELECT ship_id FROM ship EXCEPT SELECT ship_id FROM captain
SELECT name ,  CLASS FROM ship WHERE ship_id NOT IN (SELECT ship_id FROM captain)
Final question: what are the names and classes of the ships that do not have any captain yet?
Final SQL: SELECT name ,  CLASS FROM ship WHERE ship_id NOT IN (SELECT ship_id FROM captain)
Database: ship_1
Question sequence:
Who is the youngest captain?
Which ship does he steer?
SQL query sequence:
SELECT name from captain order by age asc limit 1
SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id  =  t2.ship_id ORDER BY t2.age LIMIT 1
Final question: Find the name of the ship that is steered by the youngest captain.
Final SQL: SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id  =  t2.ship_id ORDER BY t2.age LIMIT 1
Database: ship_1
Question sequence:
Which ship ids are steered by captains with the Midshipman rank?
Which are not?
What are their names and flags?
SQL query sequence:
SELECT DISTINCT ship_id FROM captain WHERE rank  =  'Midshipman'
SELECT ship_id from ship EXCEPT SELECT ship_id FROM captain WHERE rank  =  'Midshipman'
SELECT name ,  flag FROM ship WHERE ship_id NOT IN (SELECT ship_id FROM captain WHERE rank  =  'Midshipman')
Final question: Find the name and flag of ships that are not steered by any captain with Midshipman rank.
Final SQL: SELECT name ,  flag FROM ship WHERE ship_id NOT IN (SELECT ship_id FROM captain WHERE rank  =  'Midshipman')
Database: game_injury
Question sequence:
Show me the names of all the stadiums.
How many home games did each of them hold?
Show me the maxium, minimum, and average of them.
SQL query sequence:
SELECT name FROM Stadium
SELECT name, home_games FROM Stadium
SELECT max(home_games) ,  min(home_games) ,  avg(home_games) FROM stadium
Final question: What are the maximum, minimum and average home games each stadium held?
Final SQL: SELECT max(home_games) ,  min(home_games) ,  avg(home_games) FROM stadium
Database: game_injury
Question sequence:
Show me all the players who got injured.
Show me the date of the game that causes Walter Samuel to get injured?
What about its season?
SQL query sequence:
SELECT Player FROM injury_accident
SELECT T1.Date FROM game AS T1 JOIN injury_accident AS T2 ON T1.id  =  T2.game_id WHERE T2.player  =  'Walter Samuel'
SELECT T1.season FROM game AS T1 JOIN injury_accident AS T2 ON T1.id  =  T2.game_id WHERE T2.player  =  'Walter Samuel'
Final question: What is the season of the game which causes the player 'Walter Samuel' to get injured?
Final SQL: SELECT T1.season FROM game AS T1 JOIN injury_accident AS T2 ON T1.id  =  T2.game_id WHERE T2.player  =  'Walter Samuel'
Database: game_injury
Question sequence:
Show me all the players who got injured.
What about their game ids?
Which games caused at least two injury accidents?
Show me their ids, scores, and dates.
SQL query sequence:
SELECT Player FROM injury_accident
SELECT Player, game_id FROM injury_accident
SELECT game_id FROM injury_accident GROUP BY game_id HAVING count(*)  >=  2
SELECT T1.id ,  T1.score ,  T1.date FROM game AS T1 JOIN injury_accident AS T2 ON T2.game_id  =  T1.id GROUP BY T1.id HAVING count(*)  >=  2
Final question: What are the ids, scores, and dates of the games which caused at least two injury accidents?
Final SQL: SELECT T1.id ,  T1.score ,  T1.date FROM game AS T1 JOIN injury_accident AS T2 ON T2.game_id  =  T1.id GROUP BY T1.id HAVING count(*)  >=  2
Database: game_injury
Question sequence:
Show me all the injury accidents.
Show me distinct names of the stadium in which those accidents happened.
Show me the id and name of the one where the most injury accidents happened.
SQL query sequence:
SELECT * FROM injury_accident
SELECT distinct T1.name FROM stadium AS T1 JOIN game AS T2 ON T1.id  =  T2.stadium_id JOIN injury_accident AS T3 ON T2.id  =  T3.game_id
SELECT T1.id ,  T1.name FROM stadium AS T1 JOIN game AS T2 ON T1.id  =  T2.stadium_id JOIN injury_accident AS T3 ON T2.id  =  T3.game_id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1
Final question: What are the id and name of the stadium where the most injury accidents happened?
Final SQL: SELECT T1.id ,  T1.name FROM stadium AS T1 JOIN game AS T2 ON T1.id  =  T2.stadium_id JOIN injury_accident AS T3 ON T2.id  =  T3.game_id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1
Database: game_injury
Question sequence:
Show me all the injuries.
Show me the ids of the games where those of 'Foot injury' or 'Knee problem' happened.
What about their seasons and stadiums?
SQL query sequence:
SELECT injury FROM injury_accident
SELECT game_id FROM injury_accident WHERE injury = 'Foot injury' OR injury  =  'Knee problem'
SELECT T1.season ,  T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id WHERE T3.injury  =  'Foot injury' OR T3.injury  =  'Knee problem'
Final question: In which season and which stadium did any player have an injury of 'Foot injury' or 'Knee problem'?
Final SQL: SELECT T1.season ,  T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id WHERE T3.injury  =  'Foot injury' OR T3.injury  =  'Knee problem'
Database: game_injury
Question sequence:
How many industry accidents are there?
Show me their game ids.
Which games are not one of them?
How many are there?
SQL query sequence:
SELECT count(*) FROM injury_accident
SELECT game_id FROM injury_accident
SELECT id FROM game WHERE id NOT IN ( SELECT game_id FROM injury_accident )
SELECT count(*) FROM game WHERE id NOT IN ( SELECT game_id FROM injury_accident )
Final question: How many games are free of injury accidents?
Final SQL: SELECT count(*) FROM game WHERE id NOT IN ( SELECT game_id FROM injury_accident )
Database: game_injury
Question sequence:
Show me all distinct kinds of injuries.
What about those happened after season 2010?
How many are there?
SQL query sequence:
SELECT distinct injury FROM injury_accident
SELECT DISTINCT T1.injury FROM injury_accident AS T1 JOIN game AS T2 ON T1.game_id  =  T2.id WHERE T2.season  >  2010
SELECT count(DISTINCT T1.injury) FROM injury_accident AS T1 JOIN game AS T2 ON T1.game_id  =  T2.id WHERE T2.season  >  2010
Final question: How many distinct kinds of injuries happened after season 2010?
Final SQL: SELECT count(DISTINCT T1.injury) FROM injury_accident AS T1 JOIN game AS T2 ON T1.game_id  =  T2.id WHERE T2.season  >  2010
Database: game_injury
Question sequence:
Show me the name of players that got injured?
Give me the id of the games where Walter Samuel and Thiago Motta got injured.
What about the name of the stadium where both of them got injured?
SQL query sequence:
SELECT player FROM injury_accident
SELECT game_id FROM injury_accident where player = 'Walter Samuel' or player = 'Thiago Motta'
SELECT T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id WHERE T3.player  =  'Walter Samuel' INTERSECT SELECT T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id WHERE T3.player  =  'Thiago Motta'
Final question: List the name of the stadium where both the player 'Walter Samuel' and the player 'Thiago Motta' got injured.
Final SQL: SELECT T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id WHERE T3.player  =  'Walter Samuel' INTERSECT SELECT T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id WHERE T3.player  =  'Thiago Motta'
Database: game_injury
Question sequence:
Show me the game ids of all the injury accidents.
Which stadium did each of them happen?
Show me the name of stadiums which are not one of those.
Also show me their average attendance and total attendance.
SQL query sequence:
SELECT game_id FROM injury_accident
SELECT T2.name , T3.game_id FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id group by T3.game_id
SELECT name FROM stadium EXCEPT SELECT T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id group by T3.game_id
SELECT name ,  average_attendance ,  total_attendance FROM stadium EXCEPT SELECT T2.name ,  T2.average_attendance ,  T2.total_attendance FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id
Final question: Show the name, average attendance, total attendance for stadiums where no accidents happened.
Final SQL: SELECT name ,  average_attendance ,  total_attendance FROM stadium EXCEPT SELECT T2.name ,  T2.average_attendance ,  T2.total_attendance FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id
Database: game_injury
Question sequence:
Show me the name of all the stadiums.
Which one contains "Bank" in it?
SQL query sequence:
SELECT name FROM stadium
SELECT name FROM stadium WHERE name LIKE "%Bank%"
Final question: Which stadium name contains the substring "Bank"?
Final SQL: SELECT name FROM stadium WHERE name LIKE "%Bank%"
Database: game_injury
Question sequence:
Show me the name of all the stadiums.
How many games has each of them held?
SQL query sequence:
SELECT name FROM stadium
SELECT T1.name ,  count(*) FROM stadium AS T1 JOIN game AS T2 ON T1.id  =  T2.stadium_id GROUP BY T1.id
Final question: How many games has each stadium held?
Final SQL: SELECT T1.name ,  count(*) FROM stadium AS T1 JOIN game AS T2 ON T1.id  =  T2.stadium_id GROUP BY T1.id
Database: small_bank_1
Question sequence:
How many savings accounts are there?
What are their saving balances?
Remove Brown's saving balance.
What is the total of these saving balances?
SQL query sequence:
SELECT count(custid) FROM accounts
SELECT T2.balance FROM accounts as T1 JOIN savings as T2 on T1.custid = T2.custid
SELECT T2.balance FROM accounts as T1 JOIN savings as T2 on T1.custid = T2.custid where T1.name != "Brown"
SELECT sum(T2.balance) FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid WHERE T1.name != 'Brown'
Final question: Find the total savings balance of all accounts except the account with name ‘Brown’.
Final SQL: SELECT sum(T2.balance) FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid WHERE T1.name != 'Brown'
Database: small_bank_1
Question sequence:
What is the maximum savings balance?
What is the average?
Who are names of the people that are above this average?
How many of them are there?
SQL query sequence:
SELECT max(balance)FROM savings
SELECT avg(balance) FROM savings
SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid  =  T2.custid where T2.balance > (SELECT avg(balance) FROM savings)
SELECT count(*) FROM savings WHERE balance  >  (SELECT avg(balance) FROM savings)
Final question: How many accounts have a savings balance above the average savings balance?
Final SQL: SELECT count(*) FROM savings WHERE balance  >  (SELECT avg(balance) FROM savings)
Database: small_bank_1
Question sequence:
What account has the maximum checking balance?
What is the checking balance?
Show all the account names that have checking balances lower than this.
also provide their ids.
SQL query sequence:
SELECT custid FROM checking where balance = (SELECT max(balance) FROM checking)
SELECT max(balance) FROM checking
SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid WHERE T2.balance  <  (SELECT max(balance) FROM checking)
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)
Final question: Find the name and id of accounts whose checking balance is below the maximum checking balance.
Final 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)