query_id
int64 0
2.15k
| database_id
stringclasses 40
values | table_id
listlengths 1
4
| query
stringlengths 22
185
| answer
stringlengths 22
608
| difficulty
stringclasses 4
values |
---|---|---|---|---|---|
1,100 |
pilot_1
|
[
"pilotskills"
] |
Return the names of pilots who are younger than average, ordered by age ascending.
|
SELECT pilot_name FROM PilotSkills WHERE age < (SELECT avg(age) FROM PilotSkills) ORDER BY age
|
extra
|
1,101 |
pilot_1
|
[
"pilotskills"
] |
Find all information of on pilots whose age is less than 30.
|
SELECT * FROM PilotSkills WHERE age < 30
|
easy
|
1,102 |
pilot_1
|
[
"pilotskills"
] |
What is all the information about pilots who are younger than 30 ?
|
select * from pilotskills where age < 30
|
easy
|
1,103 |
pilot_1
|
[
"pilotskills"
] |
Find the names of all pilots who have a plane named Piper Cub and is under 35.
|
SELECT pilot_name FROM PilotSkills WHERE age < 35 AND plane_name = 'Piper Cub'
|
medium
|
1,104 |
pilot_1
|
[
"pilotskills"
] |
What are the names of pilots who are younger than 35 and have a plane named Piper Cub?
|
SELECT pilot_name FROM PilotSkills WHERE age < 35 AND plane_name = 'Piper Cub'
|
medium
|
1,105 |
pilot_1
|
[
"hangar"
] |
Where is the plane F-14 Fighter located?
|
SELECT LOCATION FROM hangar WHERE plane_name = 'F-14 Fighter'
|
easy
|
1,106 |
pilot_1
|
[
"hangar"
] |
Return the location of the hangar in which F-14 Fighter is located.
|
SELECT LOCATION FROM hangar WHERE plane_name = 'F-14 Fighter'
|
easy
|
1,107 |
pilot_1
|
[
"hangar"
] |
How many different places have some plane?
|
SELECT count(DISTINCT LOCATION) FROM hangar
|
easy
|
1,108 |
pilot_1
|
[
"hangar"
] |
Count the number of different locations of hangars.
|
SELECT count(DISTINCT LOCATION) FROM hangar
|
easy
|
1,109 |
pilot_1
|
[
"pilotskills"
] |
Which plane does the pilot Jones with age 32 has?
|
SELECT plane_name FROM pilotskills WHERE pilot_name = 'Jones' AND age = 32
|
medium
|
1,110 |
pilot_1
|
[
"pilotskills"
] |
What are the names of planes that the pilot Jones who is 32 has?
|
SELECT plane_name FROM pilotskills WHERE pilot_name = 'Jones' AND age = 32
|
medium
|
1,111 |
pilot_1
|
[
"pilotskills"
] |
How many pilots who are older than 40?
|
SELECT count(*) FROM pilotskills WHERE age > 40
|
easy
|
1,112 |
pilot_1
|
[
"pilotskills"
] |
Count the number of pilots with age greater than 40.
|
SELECT count(*) FROM pilotskills WHERE age > 40
|
easy
|
1,113 |
pilot_1
|
[
"pilotskills"
] |
How many plane B-52 Bomber owned by the pilot who is under 35?
|
SELECT count(*) FROM pilotskills WHERE age < 35 AND plane_name = 'B-52 Bomber'
|
medium
|
1,114 |
pilot_1
|
[
"pilotskills"
] |
Count the number of B-52 Bombers owned by pilots under 35.
|
SELECT count(*) FROM pilotskills WHERE age < 35 AND plane_name = 'B-52 Bomber'
|
medium
|
1,115 |
pilot_1
|
[
"pilotskills"
] |
Who is the youngest pilot to fly the plane Piper Cub?
|
SELECT pilot_name FROM pilotskills WHERE plane_name = 'Piper Cub' ORDER BY age LIMIT 1
|
hard
|
1,116 |
pilot_1
|
[
"pilotskills"
] |
Return the name of the youngest pilot to fly Piper Cub.
|
SELECT pilot_name FROM pilotskills WHERE plane_name = 'Piper Cub' ORDER BY age LIMIT 1
|
hard
|
1,117 |
pilot_1
|
[
"pilotskills"
] |
What is the name of the most popular plane?
|
SELECT plane_name FROM pilotskills GROUP BY plane_name ORDER BY count(*) DESC LIMIT 1
|
hard
|
1,118 |
pilot_1
|
[
"pilotskills"
] |
What is the name of the plane that is flown the most often?
|
SELECT plane_name FROM pilotskills GROUP BY plane_name ORDER BY count(*) DESC LIMIT 1
|
hard
|
1,119 |
pilot_1
|
[
"pilotskills"
] |
What is the name of the least popular plane?
|
SELECT plane_name FROM pilotskills GROUP BY plane_name ORDER BY count(*) LIMIT 1
|
hard
|
1,120 |
pilot_1
|
[
"pilotskills"
] |
What is the name of the plane that is flown the least often?
|
SELECT plane_name FROM pilotskills GROUP BY plane_name ORDER BY count(*) LIMIT 1
|
hard
|
1,121 |
pilot_1
|
[
"pilotskills",
"hangar"
] |
How many pilots whose planes are in Chicago?
|
SELECT count(DISTINCT T1.pilot_name) FROM pilotskills AS T1 JOIN hangar AS T2 ON T1.plane_name = T2.plane_name WHERE T2.location = 'Chicago'
|
medium
|
1,122 |
pilot_1
|
[
"pilotskills",
"hangar"
] |
Count the number of pilots who have planes in Chicago.
|
SELECT count(DISTINCT T1.pilot_name) FROM pilotskills AS T1 JOIN hangar AS T2 ON T1.plane_name = T2.plane_name WHERE T2.location = 'Chicago'
|
medium
|
1,123 |
pilot_1
|
[
"pilotskills"
] |
What are the planes owned by pilot Smith with age 41?
|
SELECT plane_name FROM pilotskills WHERE pilot_name = 'Smith' AND age = 41
|
medium
|
1,124 |
pilot_1
|
[
"pilotskills"
] |
Return the names of planes owned by the pilot whose name is Smith and is 41 years old.
|
SELECT plane_name FROM pilotskills WHERE pilot_name = 'Smith' AND age = 41
|
medium
|
1,125 |
pilot_1
|
[
"pilotskills"
] |
How many distinct planes are owned across all pilots?
|
SELECT count(DISTINCT plane_name) FROM pilotskills
|
easy
|
1,126 |
pilot_1
|
[
"pilotskills"
] |
Count the number of different plane names across all pilots.
|
SELECT count(DISTINCT plane_name) FROM pilotskills
|
easy
|
1,127 |
pilot_1
|
[
"pilotskills"
] |
How many planes are owned by the pilot whose name is Smith?
|
SELECT count(plane_name) FROM pilotskills WHERE pilot_name = 'Smith'
|
easy
|
1,128 |
pilot_1
|
[
"pilotskills"
] |
Count the number of planes Smith owns.
|
SELECT count(plane_name) FROM pilotskills WHERE pilot_name = 'Smith'
|
easy
|
1,129 |
pilot_1
|
[
"pilotskills"
] |
How many planes are controlled by the pilots whose age is older than 40?
|
SELECT count(plane_name) FROM pilotskills WHERE age > 40
|
easy
|
1,130 |
pilot_1
|
[
"pilotskills"
] |
Count the number of planes flown by pilots older than 40.
|
SELECT count(plane_name) FROM pilotskills WHERE age > 40
|
easy
|
1,131 |
pilot_1
|
[
"pilotskills"
] |
Find the names of all pilots with age between 30 and 40 sorted by their ages in ascending order.
|
SELECT pilot_name FROM pilotskills WHERE age BETWEEN 30 AND 40 ORDER BY age
|
medium
|
1,132 |
pilot_1
|
[
"pilotskills"
] |
What are the names of pilots between the ages of 30 and 40, ordered by age ascending?
|
SELECT pilot_name FROM pilotskills WHERE age BETWEEN 30 AND 40 ORDER BY age
|
medium
|
1,133 |
pilot_1
|
[
"pilotskills"
] |
List all pilot names sorted by their ages in the descending order.
|
SELECT pilot_name FROM pilotskills ORDER BY age DESC
|
easy
|
1,134 |
pilot_1
|
[
"pilotskills"
] |
What are the names of pilots, ordered by age descending?
|
SELECT pilot_name FROM pilotskills ORDER BY age DESC
|
easy
|
1,135 |
pilot_1
|
[
"hangar"
] |
Find all locations of planes sorted by the plane name.
|
SELECT LOCATION FROM hangar ORDER BY plane_name
|
easy
|
1,136 |
pilot_1
|
[
"hangar"
] |
What are the locations of the different planes, ordered by plane name?
|
SELECT LOCATION FROM hangar ORDER BY plane_name
|
easy
|
1,137 |
pilot_1
|
[
"pilotskills"
] |
List all distinct types of planes owned by all pilots in alphabetic order?
|
SELECT DISTINCT plane_name FROM pilotskills ORDER BY plane_name
|
easy
|
1,138 |
pilot_1
|
[
"pilotskills"
] |
What are the different plane names, ordered alphabetically?
|
SELECT DISTINCT plane_name FROM pilotskills ORDER BY plane_name
|
easy
|
1,139 |
pilot_1
|
[
"pilotskills"
] |
How many pilots who are older than 40 or younger than 30?
|
SELECT count(pilot_name) FROM pilotskills ORDER BY age > 40 OR age < 30
|
easy
|
1,140 |
pilot_1
|
[
"pilotskills"
] |
Count the number of pilots with age greater than 40 or less than 30.
|
SELECT count(pilot_name) FROM pilotskills ORDER BY age > 40 OR age < 30
|
easy
|
1,141 |
pilot_1
|
[
"pilotskills"
] |
What are the names and ages of pilots who own plane Piper Cub and are older than 35, or have F-14 Fighter and are younger than 30?
|
SELECT pilot_name , age FROM pilotskills WHERE plane_name = 'Piper Cub' AND age > 35 UNION SELECT pilot_name , age FROM pilotskills WHERE plane_name = 'F-14 Fighter' AND age < 30
|
extra
|
1,142 |
pilot_1
|
[
"pilotskills"
] |
Return the names and ages of pilors who have flown Piper Cub and are older than 35, or have flown the F-14 Fighter and are younger than 30.
|
SELECT pilot_name , age FROM pilotskills WHERE plane_name = 'Piper Cub' AND age > 35 UNION SELECT pilot_name , age FROM pilotskills WHERE plane_name = 'F-14 Fighter' AND age < 30
|
extra
|
1,143 |
pilot_1
|
[
"pilotskills"
] |
Find pilots who own plane Piper Cub but not B-52 Bomber.
|
SELECT pilot_name FROM pilotskills WHERE plane_name = 'Piper Cub' EXCEPT SELECT pilot_name FROM pilotskills WHERE plane_name = 'B-52 Bomber'
|
hard
|
1,144 |
pilot_1
|
[
"pilotskills"
] |
What are the names of pilots who have flown Piper Cub but not the B-52 Bomber?
|
SELECT pilot_name FROM pilotskills WHERE plane_name = 'Piper Cub' EXCEPT SELECT pilot_name FROM pilotskills WHERE plane_name = 'B-52 Bomber'
|
hard
|
1,145 |
pilot_1
|
[
"pilotskills"
] |
Find pilots who own planes Piper Cub and B-52 Bomber.
|
SELECT pilot_name FROM pilotskills WHERE plane_name = 'Piper Cub' INTERSECT SELECT pilot_name FROM pilotskills WHERE plane_name = 'B-52 Bomber'
|
hard
|
1,146 |
pilot_1
|
[
"pilotskills"
] |
What are the names of pilots who own both Piper Cub and the B-52 Bomber?
|
SELECT pilot_name FROM pilotskills WHERE plane_name = 'Piper Cub' INTERSECT SELECT pilot_name FROM pilotskills WHERE plane_name = 'B-52 Bomber'
|
hard
|
1,147 |
pilot_1
|
[
"pilotskills"
] |
What are the average and smallest ages of all pilots?
|
SELECT avg(age) , min(age) FROM pilotskills
|
medium
|
1,148 |
pilot_1
|
[
"pilotskills"
] |
Return the average and minimum ages across all pilots.
|
SELECT avg(age) , min(age) FROM pilotskills
|
medium
|
1,149 |
pilot_1
|
[
"pilotskills",
"hangar"
] |
What are the names of pilots who have planes in both Austin and Boston?
|
SELECT T1.pilot_name FROM pilotskills AS T1 JOIN hangar AS T2 ON T1.plane_name = T2.plane_name WHERE T2.location = "Austin" INTERSECT SELECT T1.pilot_name FROM pilotskills AS T1 JOIN hangar AS T2 ON T1.plane_name = T2.plane_name WHERE T2.LOCATION = "Boston"
|
extra
|
1,150 |
pilot_1
|
[
"pilotskills",
"hangar"
] |
Give the names of pilots who have planes in Austin and Boston.
|
SELECT T1.pilot_name FROM pilotskills AS T1 JOIN hangar AS T2 ON T1.plane_name = T2.plane_name WHERE T2.location = "Austin" INTERSECT SELECT T1.pilot_name FROM pilotskills AS T1 JOIN hangar AS T2 ON T1.plane_name = T2.plane_name WHERE T2.LOCATION = "Boston"
|
extra
|
1,151 |
pilot_1
|
[
"pilotskills"
] |
Find the pilots who have either plane Piper Cub or plane F-14 Fighter.
|
SELECT pilot_name FROM pilotskills WHERE plane_name = 'Piper Cub' OR plane_name = 'F-14 Fighter'
|
medium
|
1,152 |
pilot_1
|
[
"pilotskills"
] |
What are the names of pilots who have either the Piper Cub or the F-14 Fighter?
|
SELECT pilot_name FROM pilotskills WHERE plane_name = 'Piper Cub' OR plane_name = 'F-14 Fighter'
|
medium
|
1,153 |
pilot_1
|
[
"pilotskills"
] |
What is the average age of pilots for different types of planes?
|
SELECT avg(age) , plane_name FROM pilotskills GROUP BY plane_name
|
medium
|
1,154 |
pilot_1
|
[
"pilotskills"
] |
Return the average age of pilots for each plane name.
|
SELECT avg(age) , plane_name FROM pilotskills GROUP BY plane_name
|
medium
|
1,155 |
pilot_1
|
[
"pilotskills"
] |
Find the number of planes for each type.
|
SELECT count(*) , plane_name FROM pilotskills GROUP BY plane_name
|
medium
|
1,156 |
pilot_1
|
[
"pilotskills"
] |
Count the number of entries for each plane name.
|
SELECT count(*) , plane_name FROM pilotskills GROUP BY plane_name
|
medium
|
1,157 |
pilot_1
|
[
"pilotskills"
] |
Find the name of the oldest pilot for each type of plane, and order the results by plane name.
|
SELECT pilot_name , plane_name , max(age) FROM pilotskills GROUP BY plane_name ORDER BY plane_name
|
medium
|
1,158 |
pilot_1
|
[
"pilotskills"
] |
What are the different plane names, and what are the names of the oldest pilot who has each, ordered by plane name?
|
SELECT pilot_name , plane_name , max(age) FROM pilotskills GROUP BY plane_name ORDER BY plane_name
|
medium
|
1,159 |
pilot_1
|
[
"pilotskills"
] |
What are the names of oldest pilots for each type of plane?
|
SELECT pilot_name , plane_name , max(age) FROM pilotskills GROUP BY plane_name
|
medium
|
1,160 |
pilot_1
|
[
"pilotskills"
] |
Return the names of the different planes, as well as the names of the oldest pilots who flew each.
|
SELECT pilot_name , plane_name , max(age) FROM pilotskills GROUP BY plane_name
|
medium
|
1,161 |
pilot_1
|
[
"pilotskills"
] |
Find the max age for each group of pilots with the same name.
|
SELECT max(age) , pilot_name FROM pilotskills GROUP BY pilot_name
|
medium
|
1,162 |
pilot_1
|
[
"pilotskills"
] |
What are the different pilot names, and what are the maximum ages of pilots for each?
|
SELECT max(age) , pilot_name FROM pilotskills GROUP BY pilot_name
|
medium
|
1,163 |
pilot_1
|
[
"pilotskills",
"hangar"
] |
For each city, find the number and average age of pilots who have a plane.
|
SELECT count(T1.pilot_name) , avg(T1.age) , T2.location FROM pilotskills AS T1 JOIN hangar AS T2 ON T1.plane_name = T2.plane_name GROUP BY T2.location
|
extra
|
1,164 |
pilot_1
|
[
"pilotskills",
"hangar"
] |
What are the different hangar locations and how many pilots correspond to each. Also, what are their average ages?
|
SELECT count(T1.pilot_name) , avg(T1.age) , T2.location FROM pilotskills AS T1 JOIN hangar AS T2 ON T1.plane_name = T2.plane_name GROUP BY T2.location
|
extra
|
1,165 |
pilot_1
|
[
"pilotskills"
] |
Find the number of pilots for the plane types with average pilot age below 35.
|
SELECT count(*) , plane_name FROM pilotskills GROUP BY plane_name HAVING avg(age) < 35
|
medium
|
1,166 |
pilot_1
|
[
"pilotskills"
] |
What are the different plane names of planes with an average pilot age of below 35, and how many pilots have flown each of them?
|
SELECT count(*) , plane_name FROM pilotskills GROUP BY plane_name HAVING avg(age) < 35
|
medium
|
1,167 |
pilot_1
|
[
"pilotskills",
"hangar"
] |
Find the location of the plane that is owned by the youngest pilot.
|
SELECT T2.location FROM pilotskills AS T1 JOIN hangar AS T2 ON T1.plane_name = T2.plane_name WHERE T1.age = (SELECT min(age) FROM pilotskills)
|
extra
|
1,168 |
pilot_1
|
[
"pilotskills",
"hangar"
] |
What is the location of the plane that was flown by the pilot with the lowest age?
|
SELECT T2.location FROM pilotskills AS T1 JOIN hangar AS T2 ON T1.plane_name = T2.plane_name WHERE T1.age = (SELECT min(age) FROM pilotskills)
|
extra
|
1,169 |
pilot_1
|
[
"pilotskills",
"hangar"
] |
Find the name and age of pilots who have a plane in Austin.
|
SELECT T1.pilot_name , T1.age FROM pilotskills AS T1 JOIN hangar AS T2 ON T1.plane_name = T2.plane_name WHERE T2.location = "Austin"
|
medium
|
1,170 |
pilot_1
|
[
"pilotskills",
"hangar"
] |
What are the names and ages of pilots who have planes located in Austin?
|
SELECT T1.pilot_name , T1.age FROM pilotskills AS T1 JOIN hangar AS T2 ON T1.plane_name = T2.plane_name WHERE T2.location = "Austin"
|
medium
|
1,171 |
pilot_1
|
[
"pilotskills"
] |
List in alphabetic order the names of pilots whose age is greater than some pilots having plane Piper Cub.
|
SELECT pilot_name FROM pilotskills WHERE age > (SELECT min(age) FROM pilotskills WHERE plane_name = 'Piper Cub') ORDER BY pilot_name
|
extra
|
1,172 |
pilot_1
|
[
"pilotskills"
] |
Return the names of pilots who are older than any pilot who has flown Piper Cub, ordered alphabetically.
|
SELECT pilot_name FROM pilotskills WHERE age > (SELECT min(age) FROM pilotskills WHERE plane_name = 'Piper Cub') ORDER BY pilot_name
|
extra
|
1,173 |
pilot_1
|
[
"pilotskills"
] |
Find the number of pilots whose age is younger than all pilots whose plane is F-14 Fighter.
|
SELECT count(*) FROM pilotskills WHERE age < (SELECT min(age) FROM pilotskills WHERE plane_name = 'F-14 Fighter')
|
hard
|
1,174 |
pilot_1
|
[
"pilotskills"
] |
How many pilots are younger than all pilots who own the F-14 Fighter?
|
SELECT count(*) FROM pilotskills WHERE age < (SELECT min(age) FROM pilotskills WHERE plane_name = 'F-14 Fighter')
|
hard
|
1,175 |
pilot_1
|
[
"pilotskills"
] |
Find all different planes whose names contain substring 'Bomber'.
|
SELECT DISTINCT plane_name FROM pilotskills WHERE plane_name LIKE '%Bomber%'
|
medium
|
1,176 |
pilot_1
|
[
"pilotskills"
] |
What are the different plane names that contain the word Bomber?
|
SELECT DISTINCT plane_name FROM pilotskills WHERE plane_name LIKE '%Bomber%'
|
medium
|
1,177 |
pilot_1
|
[
"pilotskills"
] |
Find the number of all pilots whose age is older than some pilot who has plane Piper Cub.
|
SELECT count(pilot_name) FROM pilotskills WHERE age > (SELECT min(age) FROM pilotskills WHERE plane_name = 'Piper Cub')
|
hard
|
1,178 |
pilot_1
|
[
"pilotskills"
] |
How many pilots are older than the youngest pilot who has Piper Cub?
|
SELECT count(pilot_name) FROM pilotskills WHERE age > (SELECT min(age) FROM pilotskills WHERE plane_name = 'Piper Cub')
|
hard
|
1,179 |
district_spokesman
|
[
"district"
] |
Find the name of the district which has the largest area.
|
SELECT name FROM district ORDER BY Area_km DESC LIMIT 1
|
medium
|
1,180 |
district_spokesman
|
[
"district"
] |
Select the area and government website of the district with the smallest population.
|
SELECT area_km , Government_website FROM district ORDER BY Population LIMIT 1
|
medium
|
1,181 |
district_spokesman
|
[
"district"
] |
Find the names and populations of the districts whose area is greater than the average area.
|
SELECT name , population FROM district WHERE area_km > (SELECT avg(area_km) FROM district)
|
extra
|
1,182 |
district_spokesman
|
[
"district"
] |
Give me the biggest and average areas of all districts.
|
SELECT max(area_km) , avg(area_km) FROM district
|
medium
|
1,183 |
district_spokesman
|
[
"district"
] |
What is the total population of the districts whose areas are in the top 3?
|
SELECT sum(population) FROM district ORDER BY area_km DESC LIMIT 3
|
medium
|
1,184 |
district_spokesman
|
[
"district"
] |
List the ids, names, and government websites of all districts sorted by population.
|
SELECT name , Government_website , district_id FROM district ORDER BY Population
|
medium
|
1,185 |
district_spokesman
|
[
"district"
] |
Find the names of districts whose government links use a 'gov' domain.
|
SELECT name FROM district WHERE Government_website LIKE "%gov%"
|
medium
|
1,186 |
district_spokesman
|
[
"district"
] |
Return the ids and names of the districts whose population is larger than 4000 or area bigger than 3000.
|
SELECT district_id , name FROM district WHERE area_km > 3000 OR population > 4000
|
extra
|
1,187 |
district_spokesman
|
[
"spokesman"
] |
Find all spokesman's names and speech titles.
|
SELECT name , speach_title FROM spokesman
|
medium
|
1,188 |
district_spokesman
|
[
"spokesman"
] |
Find the average points and average ages of all spokesmen whose rank position is 1.
|
SELECT avg(points) , avg(age) FROM spokesman WHERE rank_position = 1
|
medium
|
1,189 |
district_spokesman
|
[
"spokesman"
] |
What are the names and points of spokesmen who are younger than 40?
|
SELECT name , points FROM spokesman WHERE age < 40
|
medium
|
1,190 |
district_spokesman
|
[
"spokesman"
] |
Who is the oldest spokesman?
|
SELECT name FROM spokesman ORDER BY age DESC LIMIT 1
|
medium
|
1,191 |
district_spokesman
|
[
"spokesman"
] |
Which spokesman has lower points than the average?
|
SELECT name FROM spokesman WHERE points < (SELECT avg(points) FROM spokesman)
|
hard
|
1,192 |
district_spokesman
|
[
"spokesman_district",
"district"
] |
Find the name of the district which has greatest number of spokesmen.
|
SELECT t1.name FROM district AS t1 JOIN spokesman_district AS t2 ON t1.District_ID = t2.District_ID GROUP BY t2.District_ID ORDER BY count(*) DESC LIMIT 1
|
extra
|
1,193 |
district_spokesman
|
[
"spokesman_district",
"spokesman"
] |
Find the names of spokesmen who have served some district before 2004.
|
SELECT t1.name FROM spokesman AS t1 JOIN spokesman_district AS t2 ON t1.Spokesman_ID = t2.Spokesman_ID WHERE t2.start_year < 2004
|
medium
|
1,194 |
district_spokesman
|
[
"spokesman_district",
"district"
] |
Find the number of spokesmen for each district, and the show district names as well.
|
SELECT t1.name , count(*) FROM district AS t1 JOIN spokesman_district AS t2 ON t1.District_ID = t2.District_ID GROUP BY t2.District_ID
|
medium
|
1,195 |
district_spokesman
|
[
"spokesman_district",
"spokesman",
"district"
] |
Find the names of the districts which have had both spokesman with rank position 1 and 2.
|
SELECT t3.name FROM spokesman AS t1 JOIN spokesman_district AS t2 ON t1.Spokesman_ID = t2.Spokesman_ID JOIN district AS t3 ON t3.district_id = t2.district_id WHERE t1.rank_position = 1 INTERSECT SELECT t3.name FROM spokesman AS t1 JOIN spokesman_district AS t2 ON t1.Spokesman_ID = t2.Spokesman_ID JOIN district AS t3 ON t3.district_id = t2.district_id WHERE t1.rank_position = 2
|
extra
|
1,196 |
district_spokesman
|
[
"spokesman_district",
"district"
] |
Find the names of districts which have more than one spokesman.
|
SELECT t1.name FROM district AS t1 JOIN spokesman_district AS t2 ON t1.District_ID = t2.District_ID GROUP BY t2.District_ID HAVING count(*) > 1
|
medium
|
1,197 |
district_spokesman
|
[
"spokesman_district",
"district"
] |
Find the number of districts which have no spokesmen.
|
SELECT count(*) FROM district WHERE district_id NOT IN (SELECT district_id FROM spokesman_district)
|
extra
|
1,198 |
district_spokesman
|
[
"spokesman_district",
"spokesman"
] |
Find the name of spokesmen who do not speak for any district.
|
SELECT name FROM spokesman WHERE Spokesman_ID NOT IN (SELECT Spokesman_ID FROM spokesman_district)
|
hard
|
1,199 |
district_spokesman
|
[
"spokesman_district",
"district"
] |
Find the total and average population of the districts which have some spokesman.
|
SELECT sum(population) , avg(population) FROM district WHERE district_id IN (SELECT district_id FROM spokesman_district)
|
extra
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.