spider_version
int64
1
2
db_id
stringclasses
204 values
schema
stringclasses
187 values
question
stringlengths
3
328
query
stringlengths
20
3.81k
1
gymnast
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") )
What are the total points of gymnasts, ordered by their floor exercise points descending?
SELECT Total_Points FROM gymnast ORDER BY Floor_Exercise_Points DESC
1
gymnast
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") )
What is the average horizontal bar points for all gymnasts?
SELECT avg(Horizontal_Bar_Points) FROM gymnast
1
gymnast
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") )
Return the average horizontal bar points across all gymnasts.
SELECT avg(Horizontal_Bar_Points) FROM gymnast
1
gymnast
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") )
What are the names of people in ascending alphabetical order?
SELECT Name FROM People ORDER BY Name ASC
1
gymnast
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") )
Return the names of people, ordered alphabetically.
SELECT Name FROM People ORDER BY Name ASC
1
gymnast
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") )
What are the names of gymnasts?
SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID
1
gymnast
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") )
Return the names of the gymnasts.
SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID
1
gymnast
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") )
What are the names of gymnasts whose hometown is not "Santo Domingo"?
SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID WHERE T2.Hometown != "Santo Domingo"
1
gymnast
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") )
Return the names of gymnasts who did not grow up in Santo Domingo.
SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID WHERE T2.Hometown != "Santo Domingo"
1
gymnast
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") )
What is the age of the tallest person?
SELECT Age FROM people ORDER BY Height DESC LIMIT 1
1
gymnast
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") )
Return the age of the person with the greatest height.
SELECT Age FROM people ORDER BY Height DESC LIMIT 1
1
gymnast
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") )
List the names of the top 5 oldest people.
SELECT Name FROM People ORDER BY Age DESC LIMIT 5
1
gymnast
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") )
What are the names of the five oldest people?
SELECT Name FROM People ORDER BY Age DESC LIMIT 5
1
gymnast
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") )
What is the total point count of the youngest gymnast?
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
1
gymnast
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") )
Return the total points of the gymnast with the lowest age.
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
1
gymnast
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") )
What is the average age of all gymnasts?
SELECT avg(T2.Age) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID
1
gymnast
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") )
Return the average age across all gymnasts.
SELECT avg(T2.Age) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID
1
gymnast
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") )
What are the distinct hometowns of gymnasts with total points more than 57.5?
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
1
gymnast
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") )
Give the different hometowns of gymnasts that have a total point score of above 57.5.
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
1
gymnast
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") )
What are the hometowns of gymnasts and the corresponding number of gymnasts?
SELECT T2.Hometown , COUNT(*) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown
1
gymnast
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") )
How many gymnasts are from each hometown?
SELECT T2.Hometown , COUNT(*) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown
1
gymnast
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") )
What is the most common hometown of gymnasts?
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
1
gymnast
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") )
Return the hometown that is most common among gymnasts.
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
1
gymnast
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") )
What are the hometowns that are shared by at least two gymnasts?
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
1
gymnast
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") )
Give the hometowns from which two or more gymnasts are from.
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
1
gymnast
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") )
List the names of gymnasts in ascending order by their heights.
SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T2.Height ASC
1
gymnast
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") )
What are the names of gymnasts, ordered by their heights ascending?
SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T2.Height ASC
1
gymnast
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") )
List the distinct hometowns that are not associated with any gymnast.
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
1
gymnast
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") )
From which hometowns did no gymnasts come from?
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
1
gymnast
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") )
Show the hometowns shared by people older than 23 and younger than 20.
SELECT Hometown FROM people WHERE Age > 23 INTERSECT SELECT Hometown FROM people WHERE Age < 20
1
gymnast
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") )
From which hometowns did both people older than 23 and younger than 20 come from?
SELECT Hometown FROM people WHERE Age > 23 INTERSECT SELECT Hometown FROM people WHERE Age < 20
1
gymnast
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") )
How many distinct hometowns did these people have?
SELECT count(DISTINCT Hometown) FROM people
1
gymnast
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") )
Count the number of different hometowns of these people.
SELECT count(DISTINCT Hometown) FROM people
1
gymnast
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") )
Show the ages of gymnasts in descending order of total points.
SELECT T2.Age FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T1.Total_Points DESC
1
gymnast
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") )
What are the ages of the gymnasts, ordered descending by their total points?
SELECT T2.Age FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T1.Total_Points DESC
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
How many main stream browsers whose market share is at least 5 exist?
SELECT count(*) FROM browser WHERE market_share >= 5
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
List the name of browsers in descending order by market share.
SELECT name FROM browser ORDER BY market_share DESC
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
List the ids, names and market shares of all browsers.
SELECT id , name , market_share FROM browser
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
What is the maximum, minimum and average market share of the listed browsers?
SELECT max(market_share) , min(market_share) , avg(market_share) FROM browser
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
What is the id and market share of the browser Safari?
SELECT id , market_share FROM browser WHERE name = 'Safari'
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
What are the name and os of web client accelerators that do not work with only a 'Broadband' type connection?
SELECT name , operating_system FROM web_client_accelerator WHERE CONNECTION != 'Broadband'
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
What is the name of the browser that became compatible with the accelerator 'CProxy' after year 1998 ?
SELECT T1.name FROM browser AS T1 JOIN accelerator_compatible_browser AS T2 ON T1.id = T2.browser_id JOIN web_client_accelerator AS T3 ON T2.accelerator_id = T3.id WHERE T3.name = 'CProxy' AND T2.compatible_since_year > 1998
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
What are the ids and names of the web accelerators that are compatible with two or more browsers?
SELECT T1.id , T1.Name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id GROUP BY T1.id HAVING count(*) >= 2
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
What is the id and name of the browser that is compatible with the most web accelerators?
SELECT T1.id , T1.name FROM browser AS T1 JOIN accelerator_compatible_browser AS T2 ON T1.id = T2.browser_id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
When did the web accelerator 'CACHEbox' and browser 'Internet Explorer' become compatible?
SELECT T1.compatible_since_year FROM accelerator_compatible_browser AS T1 JOIN browser AS T2 ON T1.browser_id = T2.id JOIN web_client_accelerator AS T3 ON T1.accelerator_id = T3.id WHERE T3.name = 'CACHEbox' AND T2.name = 'Internet Explorer'
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
How many different kinds of clients are supported by the web clients accelerators?
SELECT count(DISTINCT client) FROM web_client_accelerator
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
How many accelerators are not compatible with the browsers listed ?
SELECT count(*) FROM web_client_accelerator WHERE id NOT IN ( SELECT accelerator_id FROM accelerator_compatible_browser );
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
What distinct accelerator names are compatible with the browswers that have market share higher than 15?
SELECT DISTINCT T1.name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T3.market_share > 15;
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
List the names of the browser that are compatible with both 'CACHEbox' and 'Fasterfox'.
SELECT T3.name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T1.name = 'CACHEbox' INTERSECT SELECT T3.name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T1.name = 'Fasterfox'
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
Show the accelerator names and supporting operating systems that are not compatible with the browser named 'Opera'.
SELECT name , operating_system FROM web_client_accelerator EXCEPT SELECT T1.name , T1.operating_system FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T3.name = 'Opera'
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
Which accelerator name contains substring "Opera"?
SELECT name FROM web_client_accelerator WHERE name LIKE "%Opera%"
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
Find the number of web accelerators used for each Operating system.
SELECT Operating_system , count(*) FROM web_client_accelerator GROUP BY Operating_system
1
browser_web
CREATE TABLE IF NOT EXISTS "Web_client_accelerator" ( "id" int, "name" text, "Operating_system" text, "Client" text, "Connection" text, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "browser" ( "id" int, "name" text, "market_share" real, PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "accelerator_compatible_browser" ( "accelerator_id" int, "browser_id" int, "compatible_since_year" int, PRIMARY KEY("accelerator_id", "browser_id"), FOREIGN KEY ("accelerator_id") REFERENCES `Web_client_accelerator`("id"), FOREIGN KEY ("browser_id") REFERENCES `browser`("id") )
give me names of all compatible browsers and accelerators in the descending order of compatible year
SELECT T2.name , T3.name FROM accelerator_compatible_browser AS T1 JOIN browser AS T2 ON T1.browser_id = T2.id JOIN web_client_accelerator AS T3 ON T1.accelerator_id = T3.id ORDER BY T1.compatible_since_year DESC
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
How many wrestlers are there?
SELECT count(*) FROM wrestler
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Count the number of wrestlers.
SELECT count(*) FROM wrestler
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
List the names of wrestlers in descending order of days held.
SELECT Name FROM wrestler ORDER BY Days_held DESC
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What are the names of the wrestlers, ordered descending by days held?
SELECT Name FROM wrestler ORDER BY Days_held DESC
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What is the name of the wrestler with the fewest days held?
SELECT Name FROM wrestler ORDER BY Days_held ASC LIMIT 1
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Return the name of the wrestler who had the lowest number of days held.
SELECT Name FROM wrestler ORDER BY Days_held ASC LIMIT 1
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What are the distinct reigns of wrestlers whose location is not "Tokyo,Japan" ?
SELECT DISTINCT Reign FROM wrestler WHERE LOCATION != "Tokyo , Japan"
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Give the different reigns of wrestlers who are not located in Tokyo, Japan.
SELECT DISTINCT Reign FROM wrestler WHERE LOCATION != "Tokyo , Japan"
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What are the names and location of the wrestlers?
SELECT Name , LOCATION FROM wrestler
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Give the names and locations of all wrestlers.
SELECT Name , LOCATION FROM wrestler
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What are the elimination moves of wrestlers whose team is "Team Orton"?
SELECT Elimination_Move FROM Elimination WHERE Team = "Team Orton"
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Return the elimination movies of wrestlers on Team Orton.
SELECT Elimination_Move FROM Elimination WHERE Team = "Team Orton"
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What are the names of wrestlers and the elimination moves?
SELECT T2.Name , T1.Elimination_Move FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Give the names of wrestlers and their elimination moves.
SELECT T2.Name , T1.Elimination_Move FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
List the names of wrestlers and the teams in elimination in descending order of days held.
SELECT T2.Name , T1.Team FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID ORDER BY T2.Days_held DESC
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What are the names of wrestlers and their teams in elimination, ordered descending by days held?
SELECT T2.Name , T1.Team FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID ORDER BY T2.Days_held DESC
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
List the time of elimination of the wrestlers with largest days held.
SELECT T1.Time FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID ORDER BY T2.Days_held DESC LIMIT 1
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What is the time of elimination for the wrestler with the most days held?
SELECT T1.Time FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID ORDER BY T2.Days_held DESC LIMIT 1
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Show times of elimination of wrestlers with days held more than 50.
SELECT T1.Time FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID WHERE T2.Days_held > 50
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What are the times of elimination for wrestlers with over 50 days held?
SELECT T1.Time FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID WHERE T2.Days_held > 50
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Show different teams in eliminations and the number of eliminations from each team.
SELECT Team , COUNT(*) FROM elimination GROUP BY Team
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
How many eliminations did each team have?
SELECT Team , COUNT(*) FROM elimination GROUP BY Team
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Show teams that have suffered more than three eliminations.
SELECT Team FROM elimination GROUP BY Team HAVING COUNT(*) > 3
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Which teams had more than 3 eliminations?
SELECT Team FROM elimination GROUP BY Team HAVING COUNT(*) > 3
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Show the reign and days held of wrestlers.
SELECT Reign , Days_held FROM wrestler
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What are the reigns and days held of all wrestlers?
SELECT Reign , Days_held FROM wrestler
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What are the names of wrestlers days held less than 100?
SELECT Name FROM wrestler WHERE Days_held < 100
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Return the names of wrestlers with fewer than 100 days held.
SELECT Name FROM wrestler WHERE Days_held < 100
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Please show the most common reigns of wrestlers.
SELECT Reign FROM wrestler GROUP BY Reign ORDER BY COUNT(*) DESC LIMIT 1
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Which reign is the most common among wrestlers?
SELECT Reign FROM wrestler GROUP BY Reign ORDER BY COUNT(*) DESC LIMIT 1
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
List the locations that are shared by more than two wrestlers.
SELECT LOCATION FROM wrestler GROUP BY LOCATION HAVING COUNT(*) > 2
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Which locations are shared by more than two wrestlers?
SELECT LOCATION FROM wrestler GROUP BY LOCATION HAVING COUNT(*) > 2
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
List the names of wrestlers that have not been eliminated.
SELECT Name FROM wrestler WHERE Wrestler_ID NOT IN (SELECT Wrestler_ID FROM elimination)
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What are the names of wrestlers who have never been eliminated?
SELECT Name FROM wrestler WHERE Wrestler_ID NOT IN (SELECT Wrestler_ID FROM elimination)
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Show the teams that have both wrestlers eliminated by "Orton" and wrestlers eliminated by "Benjamin".
SELECT Team FROM Elimination WHERE Eliminated_By = "Orton" INTERSECT SELECT Team FROM Elimination WHERE Eliminated_By = "Benjamin"
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What are the teams that have both wrestlers eliminated by Orton and wrestlers eliminated by Benjamin?
SELECT Team FROM Elimination WHERE Eliminated_By = "Orton" INTERSECT SELECT Team FROM Elimination WHERE Eliminated_By = "Benjamin"
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What is the number of distinct teams that suffer elimination?
SELECT COUNT (DISTINCT team) FROM elimination
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
How many different teams have had eliminated wrestlers?
SELECT COUNT (DISTINCT team) FROM elimination
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
Show the times of elimination by "Punk" or "Orton".
SELECT TIME FROM elimination WHERE Eliminated_By = "Punk" OR Eliminated_By = "Orton"
1
wrestler
CREATE TABLE "wrestler" ( "Wrestler_ID" int, "Name" text, "Reign" text, "Days_held" text, "Location" text, "Event" text, PRIMARY KEY ("Wrestler_ID") ); CREATE TABLE "Elimination" ( "Elimination_ID" text, "Wrestler_ID" text, "Team" text, "Eliminated_By" text, "Elimination_Move" text, "Time" text, PRIMARY KEY ("Elimination_ID"), FOREIGN KEY ("Wrestler_ID") REFERENCES "wrestler"("Wrestler_ID") )
What are the times of elimination for any instances in which the elimination was done by Punk or Orton?
SELECT TIME FROM elimination WHERE Eliminated_By = "Punk" OR Eliminated_By = "Orton"
1
school_finance
CREATE TABLE "School" ( "School_id" text, "School_name" text, "Location" text, "Mascot" text, "Enrollment" int, "IHSAA_Class" text, "IHSAA_Football_Class" text, "County" text, PRIMARY KEY ("School_id") ); CREATE TABLE "budget" ( "School_id" int, "Year" int, "Budgeted" int, "total_budget_percent_budgeted" real, "Invested" int, "total_budget_percent_invested" real, "Budget_invested_percent" text, PRIMARY KEY("School_id","YEAR"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") ); CREATE TABLE "endowment" ( "endowment_id" int, "School_id" int, "donator_name" text, "amount" real, PRIMARY KEY("endowment_id"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") )
How many schools are there?
SELECT count(*) FROM school
1
school_finance
CREATE TABLE "School" ( "School_id" text, "School_name" text, "Location" text, "Mascot" text, "Enrollment" int, "IHSAA_Class" text, "IHSAA_Football_Class" text, "County" text, PRIMARY KEY ("School_id") ); CREATE TABLE "budget" ( "School_id" int, "Year" int, "Budgeted" int, "total_budget_percent_budgeted" real, "Invested" int, "total_budget_percent_invested" real, "Budget_invested_percent" text, PRIMARY KEY("School_id","YEAR"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") ); CREATE TABLE "endowment" ( "endowment_id" int, "School_id" int, "donator_name" text, "amount" real, PRIMARY KEY("endowment_id"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") )
Count the number of schools.
SELECT count(*) FROM school
1
school_finance
CREATE TABLE "School" ( "School_id" text, "School_name" text, "Location" text, "Mascot" text, "Enrollment" int, "IHSAA_Class" text, "IHSAA_Football_Class" text, "County" text, PRIMARY KEY ("School_id") ); CREATE TABLE "budget" ( "School_id" int, "Year" int, "Budgeted" int, "total_budget_percent_budgeted" real, "Invested" int, "total_budget_percent_invested" real, "Budget_invested_percent" text, PRIMARY KEY("School_id","YEAR"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") ); CREATE TABLE "endowment" ( "endowment_id" int, "School_id" int, "donator_name" text, "amount" real, PRIMARY KEY("endowment_id"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") )
Show all school names in alphabetical order.
SELECT school_name FROM school ORDER BY school_name
1
school_finance
CREATE TABLE "School" ( "School_id" text, "School_name" text, "Location" text, "Mascot" text, "Enrollment" int, "IHSAA_Class" text, "IHSAA_Football_Class" text, "County" text, PRIMARY KEY ("School_id") ); CREATE TABLE "budget" ( "School_id" int, "Year" int, "Budgeted" int, "total_budget_percent_budgeted" real, "Invested" int, "total_budget_percent_invested" real, "Budget_invested_percent" text, PRIMARY KEY("School_id","YEAR"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") ); CREATE TABLE "endowment" ( "endowment_id" int, "School_id" int, "donator_name" text, "amount" real, PRIMARY KEY("endowment_id"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") )
List the name, location, mascot for all schools.
SELECT school_name , LOCATION , mascot FROM school
1
school_finance
CREATE TABLE "School" ( "School_id" text, "School_name" text, "Location" text, "Mascot" text, "Enrollment" int, "IHSAA_Class" text, "IHSAA_Football_Class" text, "County" text, PRIMARY KEY ("School_id") ); CREATE TABLE "budget" ( "School_id" int, "Year" int, "Budgeted" int, "total_budget_percent_budgeted" real, "Invested" int, "total_budget_percent_invested" real, "Budget_invested_percent" text, PRIMARY KEY("School_id","YEAR"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") ); CREATE TABLE "endowment" ( "endowment_id" int, "School_id" int, "donator_name" text, "amount" real, PRIMARY KEY("endowment_id"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") )
What are the total and average enrollment of all schools?
SELECT sum(enrollment) , avg(enrollment) FROM school
1
school_finance
CREATE TABLE "School" ( "School_id" text, "School_name" text, "Location" text, "Mascot" text, "Enrollment" int, "IHSAA_Class" text, "IHSAA_Football_Class" text, "County" text, PRIMARY KEY ("School_id") ); CREATE TABLE "budget" ( "School_id" int, "Year" int, "Budgeted" int, "total_budget_percent_budgeted" real, "Invested" int, "total_budget_percent_invested" real, "Budget_invested_percent" text, PRIMARY KEY("School_id","YEAR"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") ); CREATE TABLE "endowment" ( "endowment_id" int, "School_id" int, "donator_name" text, "amount" real, PRIMARY KEY("endowment_id"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") )
What are the mascots for schools with enrollments above the average?
SELECT mascot FROM school WHERE enrollment > (SELECT avg(enrollment) FROM school)
1
school_finance
CREATE TABLE "School" ( "School_id" text, "School_name" text, "Location" text, "Mascot" text, "Enrollment" int, "IHSAA_Class" text, "IHSAA_Football_Class" text, "County" text, PRIMARY KEY ("School_id") ); CREATE TABLE "budget" ( "School_id" int, "Year" int, "Budgeted" int, "total_budget_percent_budgeted" real, "Invested" int, "total_budget_percent_invested" real, "Budget_invested_percent" text, PRIMARY KEY("School_id","YEAR"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") ); CREATE TABLE "endowment" ( "endowment_id" int, "School_id" int, "donator_name" text, "amount" real, PRIMARY KEY("endowment_id"), FOREIGN KEY("School_id") REFERENCES "School"("School_id") )
List the name of the school with the smallest enrollment.
SELECT school_name FROM school ORDER BY enrollment LIMIT 1