aherntech/sparc huggingface dataset:
Database: railway
Question sequence:
List all the ages of the managers
What is the maximum value of it?
How about the average?
SQL query sequence:
SELECT Age FROM manager
SELECT max(Age) FROM manager
SELECT avg(Age) FROM manager
Final question: What is the average age for all managers?
Final SQL: SELECT avg(Age) FROM manager
Database: railway
Question sequence:
Show the names and levels of all managers.
Only keep the name whose level is at least 7
Order all the names in ascending order of level.
SQL query sequence:
SELECT Name, Level FROM manager
SELECT Name FROM manager WHERE LEVEL >= 7
SELECT Name FROM manager ORDER BY LEVEL ASC
Final question: What are the names of managers in ascending order of level?
Final SQL: SELECT Name FROM manager ORDER BY LEVEL ASC
Database: railway
Question sequence:
Show the names of the trains.
Add the arrival time for each of them.
SQL query sequence:
SELECT Name FROM train
SELECT Name ,  Arrival FROM train
Final question: What are the names and arrival times of trains?
Final SQL: SELECT Name ,  Arrival FROM train
Database: railway
Question sequence:
Show the names and ages of all managers.
Only keep the ones whose level is at least 5.
Order all the names in descending order of the age.
Who is the oldest manager?
SQL query sequence:
SELECT Name, Age FROM manager
SELECT Name FROM manager WHERE LEVEL >= 5
SELECT Name FROM manager ORDER BY Age DESC
SELECT Name FROM manager ORDER BY Age DESC LIMIT 1
Final question: What is the name of the oldest manager?
Final SQL: SELECT Name FROM manager ORDER BY Age DESC LIMIT 1
Database: railway
Question sequence:
List the names of the trains.
Add the locations to each.
SQL query sequence:
SELECT Name FROM train
SELECT T2.Name ,  T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID
Final question: Show the names of trains and locations of railways they are in.
Final SQL: SELECT T2.Name ,  T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID
Database: railway
Question sequence:
List the train information with the name "Andaman Exp".
Which railway is it? Show the railway name.
And which builder is it?
SQL query sequence:
SELECT  * FROM train WHERE Name  =  "Andaman Exp"
SELECT T1.Railway FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID WHERE T2.Name  =  "Andaman Exp"
SELECT T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID WHERE T2.Name  =  "Andaman Exp"
Final question: Show the builder of railways associated with the trains named "Andaman Exp".
Final SQL: SELECT T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID WHERE T2.Name  =  "Andaman Exp"
Database: railway
Question sequence:
Show the builders of the railways.
List the railway id and the location of each railway.
Only keep the ones that are associated with more than one train.
SQL query sequence:
SELECT Builder FROM railway
SELECT T2.Railway_ID ,  T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID
SELECT T2.Railway_ID ,  T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID GROUP BY T2.Railway_ID HAVING COUNT(*)  >  1
Final question: Show id and location of railways that are associated with more than one train.
Final SQL: SELECT T2.Railway_ID ,  T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID GROUP BY T2.Railway_ID HAVING COUNT(*)  >  1
Database: railway
Question sequence:
Show the builders of the railways.
List the railway id and the builder for each one.
Among those results, keep the one that associated with the most trains.
SQL query sequence:
SELECT Builder FROM railway
SELECT T2.Railway_ID ,  T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID
SELECT T2.Railway_ID ,  T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID GROUP BY T2.Railway_ID ORDER BY COUNT(*) DESC LIMIT 1
Final question: Show the id and builder of the railway that are associated with the most trains.
Final SQL: SELECT T2.Railway_ID ,  T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID GROUP BY T2.Railway_ID ORDER BY COUNT(*) DESC LIMIT 1
Database: railway
Question sequence:
List all the builders about the railways.
Show each one and the corresponding counts of railways.
SQL query sequence:
SELECT Builder FROM railway
SELECT Builder, count(*) FROM railway GROUP BY LOCATION
Final question: Show different builders of railways, along with the corresponding number of railways using each builder.
Final SQL: SELECT Builder ,  COUNT(*) FROM railway GROUP BY Builder
Database: railway
Question sequence:
List all the builders.
Show the builders and the corresponding counts of each.
Which one is the most popular one?
SQL query sequence:
SELECT Builder FROM railway
SELECT Builder, count(*) FROM railway GROUP BY LOCATION
SELECT Builder FROM railway GROUP BY Builder ORDER BY COUNT(*) DESC LIMIT 1
Final question: Show the most common builder of railways.
Final SQL: SELECT Builder FROM railway GROUP BY Builder ORDER BY COUNT(*) DESC LIMIT 1
Database: railway
Question sequence:
List all the locations.
Which ones have more than one railways?
Show the locations and the corresponding counts of each.
SQL query sequence:
SELECT LOCATION FROM railway
SELECT LOCATION FROM railway GROUP BY LOCATION HAVING COUNT(*)  >  1
SELECT LOCATION, count(*) FROM railway GROUP BY LOCATION
Final question: Show different locations of railways along with the corresponding number of railways at each location.
Final SQL: SELECT LOCATION ,  COUNT(*) FROM railway GROUP BY LOCATION
Database: railway
Question sequence:
List all the locations.
What are the corresponding counts of railways?
Which locations have more than one railways?
SQL query sequence:
SELECT LOCATION FROM railway
SELECT LOCATION, count(*) FROM railway GROUP BY LOCATION
SELECT LOCATION FROM railway GROUP BY LOCATION HAVING COUNT(*)  >  1
Final question: Show the locations that have more than one railways.
Final SQL: SELECT LOCATION FROM railway GROUP BY LOCATION HAVING COUNT(*)  >  1
Database: railway
Question sequence:
Show all the information about each railway.
What are the object numbers?
Which of the railway has no trains, keep the object number.
SQL query sequence:
SELECT * FROM railway
SELECT ObjectNumber FROM railway
SELECT ObjectNumber FROM railway WHERE Railway_ID NOT IN (SELECT Railway_ID FROM train)
Final question: List the object number of railways that do not have any trains.
Final SQL: SELECT ObjectNumber FROM railway WHERE Railway_ID NOT IN (SELECT Railway_ID FROM train)
Database: railway
Question sequence:
List all the countries of the managers.
How many are there?
Keep the ones where the manager age is in the range of 50 and 46
What about the other countries?
SQL query sequence:
SELECT Country FROM manager
SELECT count (DISTINCT Country) FROM manager
SELECT Country FROM manager WHERE Age  <  50 INTERSECT SELECT Country FROM manager WHERE Age  >  46
SELECT Country FROM manager WHERE Age  >  50 INTERSECT SELECT Country FROM manager WHERE Age  <  46
Final question: Show the countries that have both managers of age above 50 and managers of age below 46.
Final SQL: SELECT Country FROM manager WHERE Age  >  50 INTERSECT SELECT Country FROM manager WHERE Age  <  46
Database: railway
Question sequence:
List all the countries of the managers.
How many unique ones are there?
SQL query sequence:
SELECT Country FROM manager
SELECT count (DISTINCT Country) FROM manager
Final question: Show the distinct countries of managers.
Final SQL: SELECT DISTINCT Country FROM manager
Database: railway
Question sequence:
List the manager names and the working years.
Which is the maximum working years?
Order the working years by the manager level.
SQL query sequence:
SELECT Name, Working_year_starts FROM manager
SELECT max(Working_year_starts) FROM manager
SELECT Working_year_starts FROM manager ORDER BY LEVEL DESC
Final question: Show the working years of managers in descending order of their level.
Final SQL: SELECT Working_year_starts FROM manager ORDER BY LEVEL DESC
Database: climbing
Question sequence:
List all the climber information.
How many records are there?
SQL query sequence:
SELECT * FROM climber
SELECT count(*) FROM climber
Final question: How many climbers are there?
Final SQL: SELECT count(*) FROM climber
Database: climbing
Question sequence:
What are the names of the climbers?
Keep the ones whose point is at least 6?
Order all the climber names in descending order of points.
SQL query sequence:
SELECT Name FROM climber
SELECT Name FROM climber where Points >= 6
SELECT Name FROM climber ORDER BY Points DESC
Final question: List the names of climbers in descending order of points.
Final SQL: SELECT Name FROM climber ORDER BY Points DESC
Database: climbing
Question sequence:
What are the names of the climbers?
Keep the ones whose point is at least 4.6?
Keep the ones whose country is "West Germany".
What about the ones whose country is not "Switzerland"?
SQL query sequence:
SELECT Name FROM climber
SELECT Name FROM climber where Points >= 4.6
SELECT Name FROM climber WHERE Country = "West Germany"
SELECT Name FROM climber WHERE Country != "Switzerland"
Final question: List the names of climbers whose country is not Switzerland.
Final SQL: SELECT Name FROM climber WHERE Country != "Switzerland"
Database: climbing
Question sequence:
Which climber comes from Switzerland?
What about United Kingdom?
List all the points of those climber.
What is the maximum point number?
SQL query sequence:
SELECT Name FROM climber WHERE Country = "Switzerland"
SELECT Name FROM climber WHERE Country != "United Kingdom"
SELECT Points FROM climber WHERE Country != "United Kingdom"
SELECT max(Points) FROM climber WHERE Country  =  "United Kingdom"
Final question: What is the maximum point for climbers whose country is United Kingdom?
Final SQL: SELECT max(Points) FROM climber WHERE Country  =  "United Kingdom"
Database: climbing
Question sequence:
List all the countries of the climbers.
How many unique countries are there?
SQL query sequence:
SELECT Country FROM climber
SELECT COUNT(DISTINCT Country) FROM climber
Final question: How many distinct countries are the climbers from?
Final SQL: SELECT COUNT(DISTINCT Country) FROM climber
Database: climbing
Question sequence:
Show all the information about the mountains.
List those results in ascending alphabetical order by the mountain names.
What are the mountain names from those results?
SQL query sequence:
SELECT * FROM mountain
SELECT * FROM mountain ORDER BY Name ASC
SELECT Name FROM mountain ORDER BY Name ASC
Final question: What are the names of mountains in ascending alphabetical order?
Final SQL: SELECT Name FROM mountain ORDER BY Name ASC
Database: climbing
Question sequence:
List all the countries of the mountains.
Keep the ones that the mountain height is more than 4985.0.
What about the height is more than 5000?
SQL query sequence:
SELECT Country FROM mountain
SELECT Country FROM mountain WHERE Height  > 4985.0
SELECT Country FROM mountain WHERE Height  >  5000
Final question: What are the countries of mountains with height bigger than 5000?
Final SQL: SELECT Country FROM mountain WHERE Height  >  5000
Database: climbing
Question sequence:
List all the names of the mountains.
Keep the ones that the mountain Prominence is more than 900.0.
So which mountain is the highest one?
SQL query sequence:
SELECT Name FROM mountain
SELECT Name FROM mountain WHERE Prominence  > 900.0
SELECT Name FROM mountain ORDER BY Height DESC LIMIT 1
Final question: What is the name of the highest mountain?
Final SQL: SELECT Name FROM mountain ORDER BY Height DESC LIMIT 1
Database: climbing
Question sequence:
List all the ranges of the mountains.
Order those results by Prominence in descending order.
Which one is the top one?
What about top 3?
SQL query sequence:
SELECT Range FROM mountain
SELECT DISTINCT Range FROM mountain ORDER BY Prominence DESC
SELECT DISTINCT Range FROM mountain ORDER BY Prominence DESC LIMIT 1
SELECT DISTINCT Range FROM mountain ORDER BY Prominence DESC LIMIT 3
Final question: List the distinct ranges of the mountains with the top 3 prominence.
Final SQL: SELECT DISTINCT Range FROM mountain ORDER BY Prominence DESC LIMIT 3
Database: climbing
Question sequence:
List all the climber names
Show the mountain names for those climbers.
SQL query sequence:
SELECT Name FROM climber mountain
SELECT T1.Name ,  T2.Name FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID  =  T2.Mountain_ID
Final question: Show names of climbers and the names of mountains they climb.
Final SQL: SELECT T1.Name ,  T2.Name FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID  =  T2.Mountain_ID
Database: climbing
Question sequence:
Show all the climber names
Also show the mountain height for those climbers.
SQL query sequence:
SELECT Name FROM climber mountain
SELECT T1.Name ,  T2.Height FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID  =  T2.Mountain_ID
Final question: Show the names of climbers and the heights of mountains they climb.
Final SQL: SELECT T1.Name ,  T2.Height FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID  =  T2.Mountain_ID
Database: climbing
Question sequence:
Which climbers have the point to be 8.0
Which one has the minimum point?
What about the maximum?
Show the mountain height of the mountain that climber has climbed.
SQL query sequence:
SELECT Name FROM climber WHERE Points = 8.0
SELECT Name FROM climber ORDER BY Points ASC LIMIT 1
SELECT Name FROM climber ORDER BY Points DESC LIMIT 1
SELECT T2.Height FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID  =  T2.Mountain_ID ORDER BY T1.Points DESC LIMIT 1
Final question: Show the height of the mountain climbed by the climber with the maximum points.
Final SQL: SELECT T2.Height FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID  =  T2.Mountain_ID ORDER BY T1.Points DESC LIMIT 1
Database: climbing
Question sequence:
List all the climber names who come from "United Kingdom".
What about from "West Germany"
Show the mountains they have climbed.
SQL query sequence:
SELECT Name FROM climber WHERE Country = "United Kingdom"
SELECT Name FROM climber WHERE Country = "West Germany"
SELECT DISTINCT T2.Name FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID  =  T2.Mountain_ID WHERE T1.Country  =  "West Germany"
Final question: Show the distinct names of mountains climbed by climbers from country "West Germany".
Final SQL: SELECT DISTINCT T2.Name FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID  =  T2.Mountain_ID WHERE T1.Country  =  "West Germany"
Database: climbing
Question sequence:
How many countries are there?
How many mountains are there in Tanzania?
What about in Uganda?
List the times used by the climbers for those mountains.
SQL query sequence:
SELECT count(*) FROM mountain
SELECT count(*) FROM mountain where country = 'Tanzania'
SELECT count(*) FROM mountain where country = 'Uganda'
SELECT T1.Time FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID  =  T2.Mountain_ID WHERE T2.Country  =  "Uganda"
Final question: Show the times used by climbers to climb mountains in Country Uganda.
Final SQL: SELECT T1.Time FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID  =  T2.Mountain_ID WHERE T2.Country  =  "Uganda"
Database: climbing
Question sequence:
How many unique countries in total?
Show the countries with the number of mountains for each of them.
SQL query sequence:
SELECT count( DISTINCT Country) FROM mountain
SELECT Country, count(*) FROM mountain GROUP BY Country
Final question: Please show the countries and the number of climbers from each country.
Final SQL: SELECT Country ,  COUNT(*) FROM climber GROUP BY Country
Database: climbing
Question sequence:
How many countries in total?
List the countries with the number of mountains for each.
Keep the country names that have only one mountain.
How about more than one mountain?
SQL query sequence:
SELECT count( DISTINCT Country) FROM mountain
SELECT Country, count(*) FROM mountain GROUP BY Country
SELECT Country FROM mountain GROUP BY Country HAVING COUNT(*)  =  1
SELECT Country FROM mountain GROUP BY Country HAVING COUNT(*)  >  1
Final question: List the countries that have more than one mountain.
Final SQL: SELECT Country FROM mountain GROUP BY Country HAVING COUNT(*)  >  1
Database: climbing
Question sequence:
List the names of all the mountains
Which of those has no climbers?
SQL query sequence:
SELECT Name FROM mountain
SELECT Name FROM mountain WHERE Mountain_ID NOT IN (SELECT Mountain_ID FROM climber)
Final question: List the names of mountains that do not have any climber.
Final SQL: SELECT Name FROM mountain WHERE Mountain_ID NOT IN (SELECT Mountain_ID FROM climber)
Database: climbing
Question sequence:
List all the countries of the mountains.
Keep the ones that the mountain height is more than 4985.0.
What about the height is more than 5600?
Keep the country names where the mountain height is within the range of 5200 to 5600.
SQL query sequence:
SELECT Country FROM mountain
SELECT Country FROM mountain WHERE Height  > 4985.0
SELECT Country FROM mountain WHERE Height  >  5600
SELECT Country FROM mountain WHERE Height  >  5600 INTERSECT SELECT Country FROM mountain WHERE Height  <  5200
Final question: Show the countries that have mountains with height more than 5600 stories and mountains with height less than 5200.
Final SQL: SELECT Country FROM mountain WHERE Height  >  5600 INTERSECT SELECT Country FROM mountain WHERE Height  <  5200
Database: climbing
Question sequence:
List all the ranges of mountains.
How many unique ranges are there?
How many mountains in each range?
Which one has the largest number of mountains?
SQL query sequence:
SELECT Range FROM mountain
SELECT count(DISTINCT Range) FROM mountain
SELECT Range, count (*) FROM mountain GROUP BY Range
SELECT Range FROM mountain GROUP BY Range ORDER BY COUNT(*) DESC LIMIT 1
Final question: Show the range that has the most number of mountains.
Final SQL: SELECT Range FROM mountain GROUP BY Range ORDER BY COUNT(*) DESC LIMIT 1
Database: device
Question sequence:
List all the devices
How many are there?
SQL query sequence:
SELECT * FROM device
SELECT count(*) FROM device
Final question: How many devices are there?
Final SQL: SELECT count(*) FROM device
Database: device
Question sequence:
List all the carrier names of each device
How many are there?
Order the carrier names in ascending order.
SQL query sequence:
SELECT Carrier FROM device
SELECT count (DISTINCT Carrier) FROM device
SELECT Carrier FROM device ORDER BY Carrier ASC
Final question: List the carriers of devices in ascending alphabetical order.
Final SQL: SELECT Carrier FROM device ORDER BY Carrier ASC
Database: device
Question sequence:
List the carrier name and software platform of each device
How many of them use Android as software platform?
What about not Android?
What are the carrier names of them?
SQL query sequence:
SELECT Carrier, Software_Platform FROM device
SELECT count(*) FROM device where Software_Platform = 'Android'
SELECT count(*) FROM device where Software_Platform != 'Android'
SELECT Carrier FROM device WHERE Software_Platform != 'Android'
Final question: What are the carriers of devices whose software platforms are not "Android"?
Final SQL: SELECT Carrier FROM device WHERE Software_Platform != 'Android'
Database: device
Question sequence:
List the shop names and their open year.
Keep the shop names, then show those names in ascending order of open year.
SQL query sequence:
SELECT Shop_Name, Open_Year FROM shop
SELECT Shop_Name FROM shop ORDER BY Open_Year ASC
Final question: What are the names of shops in ascending order of open year?
Final SQL: SELECT Shop_Name FROM shop ORDER BY Open_Year ASC
Database: device
Question sequence:
What is the minimum quantity of stocks?
What about the average value?
SQL query sequence:
SELECT min(Quantity) FROM stock
SELECT avg(Quantity) FROM stock
Final question: What is the average quantity of stocks?
Final SQL: SELECT avg(Quantity) FROM stock
Database: device
Question sequence:
List all the names of the shop and their locations
Order those results in ascending alphabetical order of name.
SQL query sequence:
SELECT Shop_Name ,  LOCATION FROM shop
SELECT Shop_Name ,  LOCATION FROM shop ORDER BY Shop_Name ASC
Final question: What are the names and location of the shops in ascending alphabetical order of name.
Final SQL: SELECT Shop_Name ,  LOCATION FROM shop ORDER BY Shop_Name ASC
Database: device
Question sequence:
Show all in the information about devices.
What are the unique software platforms
How many are there?
SQL query sequence:
SELECT * FROM device
SELECT DISTINCT Software_Platform FROM device
SELECT count(DISTINCT Software_Platform) FROM device
Final question: How many different software platforms are there for devices?
Final SQL: SELECT count(DISTINCT Software_Platform) FROM device
Database: device
Question sequence:
Show the information about the shops that are not "Apple".
How about the shops are "Apple"?
What are the open dates and open years of them?
SQL query sequence:
SELECT * FROM shop WHERE Shop_Name  !=  "Apple"
SELECT * FROM shop WHERE Shop_Name  =  "Apple"
SELECT Open_Date ,  Open_Year FROM shop WHERE Shop_Name  =  "Apple"
Final question: List the open date of open year of the shop named "Apple".
Final SQL: SELECT Open_Date ,  Open_Year FROM shop WHERE Shop_Name  =  "Apple"
Database: device
Question sequence:
List the names and open year of all the shops.
Keep those opens later than 2010?
Order all the shop names by the open year, from early to late.
Show the name of the shop with the latest open year.
SQL query sequence:
SELECT Shop_Name, Open_Year FROM shop
SELECT Shop_Name, Open_Year FROM shop where open_year > 2010
SELECT Shop_Name, open_year FROM shop ORDER BY Open_Year
SELECT Shop_Name FROM shop ORDER BY Open_Year DESC LIMIT 1
Final question: List the name of the shop with the latest open year.
Final SQL: SELECT Shop_Name FROM shop ORDER BY Open_Year DESC LIMIT 1
Database: device
Question sequence:
List the shop names.
Keep the names where there is a stock
Keep the names of shops and the carriers of devices where there is a stock.
SQL query sequence:
SELECT Shop_Name from shop
SELECT T1.Shop_Name from shop as T1 join stock as T2 on T1.shop_id = T2.shop_id
SELECT T3.Shop_Name ,  T2.Carrier FROM stock AS T1 JOIN device AS T2 ON T1.Device_ID  =  T2.Device_ID JOIN shop AS T3 ON T1.Shop_ID  =  T3.Shop_ID
Final question: Show names of shops and the carriers of devices they have in stock.
Final SQL: SELECT T3.Shop_Name ,  T2.Carrier FROM stock AS T1 JOIN device AS T2 ON T1.Device_ID  =  T2.Device_ID JOIN shop AS T3 ON T1.Shop_ID  =  T3.Shop_ID
Database: device
Question sequence:
List all the shop names.
List all the shop names that has stock in the shops.
Among those, keep the shop names whose open year is later than 2010
List the names of shops that have more than one kind of device in stock.
SQL query sequence:
SELECT Shop_Name FROM shop
SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID  =  T2.Shop_ID GROUP BY T1.Shop_ID
SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID  =  T2.Shop_ID GROUP BY T1.Shop_ID Having T2.Open_Year > 2010
SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID  =  T2.Shop_ID GROUP BY T1.Shop_ID HAVING COUNT(*)  >  1
Final question: Show names of shops that have more than one kind of device in stock.
Final SQL: SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID  =  T2.Shop_ID GROUP BY T1.Shop_ID HAVING COUNT(*)  >  1
Database: device
Question sequence:
List all the shop names.
Which shop has the least quantity of devices, show the shop name.
What about the shop that has the most kind of devices in stock?
SQL query sequence:
SELECT Shop_Name FROM shop
SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID  =  T2.Shop_ID GROUP BY T1.Shop_ID ORDER BY SUM(T1.quantity) ASC LIMIT 1
SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID  =  T2.Shop_ID GROUP BY T1.Shop_ID ORDER BY COUNT(*) DESC LIMIT 1
Final question: Show the name of the shop that has the most kind of devices in stock.
Final SQL: SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID  =  T2.Shop_ID GROUP BY T1.Shop_ID ORDER BY COUNT(*) DESC LIMIT 1