question_id int64 5 1.53k | db_id stringclasses 11 values | question stringlengths 23 286 | evidence stringlengths 0 468 | SQL stringlengths 35 1.58k | difficulty stringclasses 3 values |
|---|---|---|---|---|---|
895 | formula_1 | What is the average lap time for Lewis Hamilton in the 2009 Malaysian Grand Prix? | average lap time = AVG(milliseconds); 'Lewis Hamilton' refers to the full name of the driver; Full name of the driver refers to drivers.forename and drivers.surname; 'Malaysian Grand Prix' refers to races.name = 'Malaysian Grand Prix' | SELECT
AVG(`T2`.`milliseconds`)
FROM `races` AS `T1`
INNER JOIN `lapTimes` AS `T2`
ON `T2`.`raceId` = `T1`.`raceId`
INNER JOIN `drivers` AS `T3`
ON `T3`.`driverId` = `T2`.`driverId`
WHERE
`T3`.`forename` = 'Lewis'
AND `T3`.`surname` = 'Hamilton'
AND `T1`.`year` = 2009
AND `T1`.`name` = 'Malaysian Grand Prix' | moderate |
896 | formula_1 | Calculate the percentage whereby Hamilton was not at the 1st track of the the f1 circuit since 2010. | percentage = DIVIDE(COUNT(raceId) where surname = 'Hamilton' and position>1), (COUNT(raceId) where surname = 'Hamilton'); since 2010 refers to year >= 2010 | SELECT
CAST(COUNT(CASE WHEN `T2`.`position` <> 1 THEN `T2`.`position` END) AS DOUBLE) * 100 / COUNT(`T2`.`driverStandingsId`)
FROM `races` AS `T1`
INNER JOIN `driverStandings` AS `T2`
ON `T2`.`raceId` = `T1`.`raceId`
INNER JOIN `drivers` AS `T3`
ON `T3`.`driverId` = `T2`.`driverId`
WHERE
`T3`.`surname` = 'Hamilton' AND `T1`.`year` >= 2010 | challenging |
897 | formula_1 | Name the driver with the most winning. Mention his nationality and what is his maximum point scores. | Full name of the driver refers to drivers.forename and drivers.surname; the most winning refers to MAX(COUNT(wins)); average point scores refers to MAX(points); | SELECT
`T1`.`forename`,
`T1`.`surname`,
`T1`.`nationality`,
MAX(`T2`.`points`)
FROM `drivers` AS `T1`
INNER JOIN `driverStandings` AS `T2`
ON `T2`.`driverId` = `T1`.`driverId`
WHERE
`T2`.`wins` >= 1
GROUP BY
`T1`.`forename`,
`T1`.`surname`,
`T1`.`nationality`
ORDER BY
COUNT(`T2`.`wins`) DESC
LIMIT 1 | moderate |
898 | formula_1 | How old is the youngest Japanese driver? What is his name? | date of birth refers to drivers.dob; The larger the birthday value, the younger the person is, and vice versa; Japanese refers to nationality = 'Japanese'; age = YEAR(CURRENT_TIMESTAMP) - YEAR(dob); | SELECT
DATE_FORMAT(CAST(CURRENT_TIMESTAMP() AS DATETIME), '%Y') - DATE_FORMAT(CAST(`dob` AS DATETIME), '%Y'),
`forename`,
`surname`
FROM `drivers`
WHERE
`nationality` = 'Japanese'
ORDER BY
`dob` DESC
LIMIT 1 | simple |
901 | formula_1 | Name the races along with its circuit name and location for f1 races hosted in September 2005. | in September 2005 refers to MONTH(date) = 9 and YEAR(date) = 2005 | SELECT DISTINCT
`T2`.`name`,
`T1`.`name`,
`T1`.`location`
FROM `circuits` AS `T1`
INNER JOIN `races` AS `T2`
ON `T2`.`circuitID` = `T1`.`circuitId`
WHERE
`T2`.`year` = 2005 AND DATE_FORMAT(CAST(`T2`.`date` AS DATETIME), '%m') = '09' | simple |
902 | formula_1 | Which race was Alex Yoong in when he was in track number less than 20? | Alex Yoong refers to the full name of the driver; Full name of the driver refers to drivers.forename and drivers.surname;track number less than 10 refers to position < 20 | SELECT
`T1`.`name`
FROM `races` AS `T1`
INNER JOIN `driverStandings` AS `T2`
ON `T2`.`raceId` = `T1`.`raceId`
INNER JOIN `drivers` AS `T3`
ON `T3`.`driverId` = `T2`.`driverId`
WHERE
`T3`.`forename` = 'Alex' AND `T3`.`surname` = 'Yoong' AND `T2`.`position` < 20 | simple |
904 | formula_1 | State the race and year of race in which Michael Schumacher had his fastest lap. | fastest lap refers to min(milliseconds); Alex Yoong refers to the full name of the driver; Full name of the driver refers to drivers.forename and drivers.surname; | SELECT
`T1`.`name`,
`T1`.`year`
FROM `races` AS `T1`
INNER JOIN `lapTimes` AS `T2`
ON `T2`.`raceId` = `T1`.`raceId`
INNER JOIN `drivers` AS `T3`
ON `T3`.`driverId` = `T2`.`driverId`
WHERE
`T3`.`forename` = 'Michael' AND `T3`.`surname` = 'Schumacher'
ORDER BY
`T2`.`milliseconds` ASC
LIMIT 1 | moderate |
906 | formula_1 | Which was Lewis Hamilton first race? What was his points recorded for his first race event? | first race refers to min(Year); Lewis Hamiltonrefers to the full name of the driver; Full name of the driver refers to drivers.forename and drivers.surname; | SELECT
`T1`.`name`,
`T2`.`points`
FROM `races` AS `T1`
INNER JOIN `driverStandings` AS `T2`
ON `T2`.`raceId` = `T1`.`raceId`
INNER JOIN `drivers` AS `T3`
ON `T3`.`driverId` = `T2`.`driverId`
WHERE
`T3`.`forename` = 'Lewis' AND `T3`.`surname` = 'Hamilton'
ORDER BY
`T1`.`year` ASC
LIMIT 1 | moderate |
909 | formula_1 | Among all European Grand Prix races, what is the percentage of the races were hosted in Germany? | European Grand Prix races refers to races.name = 'European Grand Prix';percentage = divide(COUNT(races where country = Germany and name = 'Europearn Grand Prix'),COUNT(races where name = 'Europearn Grand Prix'))*100 | SELECT
CAST(COUNT(CASE WHEN `T1`.`country` = 'Germany' THEN `T2`.`circuitID` END) AS DOUBLE) * 100 / COUNT(`T2`.`circuitId`)
FROM `circuits` AS `T1`
INNER JOIN `races` AS `T2`
ON `T2`.`circuitID` = `T1`.`circuitId`
WHERE
`T2`.`name` = 'European Grand Prix' | moderate |
910 | formula_1 | What's the location coordinates of Silverstone Circuit? | location coordinates refers to (lat, lng); Silverstone Circuit refers to circuits.name = 'Silverstone Circuit' | SELECT
`lat`,
`lng`
FROM `circuits`
WHERE
`name` = 'Silverstone Circuit' | simple |
912 | formula_1 | What's the reference name of Marina Bay Street Circuit? | reference name refers to circuitRef; Marina Bay Street Circuit refers to circuits.name = 'Marina Bay Street Circuit' | SELECT
`circuitRef`
FROM `circuits`
WHERE
`name` = 'Marina Bay Street Circuit' | simple |
915 | formula_1 | Which country is the oldest driver from? | date of birth refers to drivers.dob; The larger the birthday value, the younger the person is, and vice versa; | SELECT
`nationality`
FROM `drivers`
WHERE
NOT `dob` IS NULL
ORDER BY
`dob` ASC
LIMIT 1 | simple |
928 | formula_1 | Which driver ranked the first in the Canadian Grand Prix in 2007? Please give his reference name. | reference name refers to driverRef; Canadian Grand Prix refers to races.name = 'Canadian Grand Prix'; | SELECT
`T3`.`forename`,
`T3`.`surname`,
`T3`.`driverRef`
FROM `races` AS `T1`
INNER JOIN `results` AS `T2`
ON `T2`.`raceId` = `T1`.`raceId`
INNER JOIN `drivers` AS `T3`
ON `T3`.`driverId` = `T2`.`driverId`
WHERE
`T1`.`name` = 'Canadian Grand Prix' AND `T2`.`rank` = 1 AND `T1`.`year` = 2007 | moderate |
930 | formula_1 | In which Formula_1 race did Lewis Hamilton rank the highest? | rank the highest refers to min(rank); Lewis Hamilton refers to the full name of the driver; Full name of the driver refers to drivers.forename and drivers.surname; | SELECT
`name`
FROM `races`
WHERE
`raceId` IN (
SELECT
`raceId`
FROM `results`
WHERE
`rank` = 1
AND `driverId` = (
SELECT
`driverId`
FROM `drivers`
WHERE
`forename` = 'Lewis' AND `surname` = 'Hamilton'
)
) | simple |
931 | formula_1 | What was the fastest lap speed among all drivers in the 2009 Spanish Grand Prix? | the fastest lap speed among all refers to max(fastestLapSpeed); Spanish Grand Prix refers to races.name = 'Spanish Grand Prix'; | SELECT
`T2`.`fastestLapSpeed`
FROM `races` AS `T1`
INNER JOIN `results` AS `T2`
ON `T2`.`raceId` = `T1`.`raceId`
WHERE
`T1`.`name` = 'Spanish Grand Prix'
AND `T1`.`year` = 2009
AND NOT `T2`.`fastestLapSpeed` IS NULL
ORDER BY
`T2`.`fastestLapSpeed` DESC
LIMIT 1 | moderate |
933 | formula_1 | What was Lewis Hamilton's final rank in the 2008 Chinese Grand Prix? | Lewis Hamilton refers to the full name of the driver; Full name of the driver refers to drivers.forename and drivers.surname; final rank refers to positionOrder; Chinese Grand Prix refers to races.name = 'Chinese Grand Prix'; | SELECT
`T2`.`positionOrder`
FROM `races` AS `T1`
INNER JOIN `results` AS `T2`
ON `T2`.`raceId` = `T1`.`raceId`
INNER JOIN `drivers` AS `T3`
ON `T3`.`driverId` = `T2`.`driverId`
WHERE
`T3`.`forename` = 'Lewis'
AND `T3`.`surname` = 'Hamilton'
AND `T1`.`name` = 'Chinese Grand Prix'
AND `T1`.`year` = 2008 | moderate |
937 | formula_1 | What's the finish time for the driver who ranked second in 2008's Chinese Grand Prix? | finish time refers to time; Chinese Grand Prix refers to races.name = 'Chinese Grand Prix'; | SELECT
`T1`.`time`
FROM `results` AS `T1`
INNER JOIN `races` AS `T2`
ON `T1`.`raceId` = `T2`.`raceId`
WHERE
`T1`.`rank` = 2 AND `T2`.`name` = 'Chinese Grand Prix' AND `T2`.`year` = 2008 | simple |
940 | formula_1 | Among the drivers that finished the race in the 2008 Chinese Grand Prix, how many of them have participated in Formula_1 races? | COUNT(raceID) > 0 reveals that this driver participated in races; drivers who finished the race refers to time has value. | SELECT COUNT(*) FROM (SELECT `T1`.`driverId` FROM `results` AS `T1` INNER JOIN `races` AS `T2` ON `T1`.`raceId` = `T2`.`raceId` WHERE `T2`.`name` = 'Chinese Grand Prix' AND `T2`.`year` = 2008 AND `T1`.`time` IS NOT NULL GROUP BY `T1`.`driverId` HAVING COUNT(`T2`.`raceId`) > 0) AS derived_table | moderate |
944 | formula_1 | How much faster in percentage is the champion than the driver who finished the race last in the 2008 Australian Grand Prix? | how much faster in percentage = divide(subtract(incremental time, champion time), last_driver time) * 100; last driver finished time = incremental time + champion time; only champion's finished time is represented by 'HH:MM:SS.mmm'; finished the game refers to time is not null | WITH `time_in_seconds` AS (
SELECT
`T1`.`positionOrder`,
CASE
WHEN `T1`.`positionOrder` = 1
THEN (
CAST(SUBSTR(`T1`.`time`, 1, 1) AS DOUBLE) * 3600
) + (
CAST(SUBSTR(`T1`.`time`, 3, 2) AS DOUBLE) * 60
) + CAST(SUBSTR(`T1`.`time`, 6) AS DOUBLE)
ELSE CAST(SUBSTR(`T1`.`time`, 2) AS DOUBLE)
END AS `time_seconds`
FROM `results` AS `T1`
INNER JOIN `races` AS `T2`
ON `T1`.`raceId` = `T2`.`raceId`
WHERE
`T2`.`name` = 'Australian Grand Prix'
AND NOT `T1`.`time` IS NULL
AND `T2`.`year` = 2008
), `champion_time` AS (
SELECT
`time_seconds`
FROM `time_in_seconds`
WHERE
`positionOrder` = 1
), `last_driver_incremental` AS (
SELECT
`time_seconds`
FROM `time_in_seconds`
WHERE
`positionOrder` = (
SELECT
MAX(`positionOrder`)
FROM `time_in_seconds`
)
)
SELECT
(
CAST((
SELECT
`time_seconds`
FROM `last_driver_incremental`
) AS DOUBLE) * 100
) / (
SELECT
`time_seconds` + (
SELECT
`time_seconds`
FROM `last_driver_incremental`
)
FROM `champion_time`
) | challenging |
945 | formula_1 | How many circuits are there in Adelaide, Australia? | Australia is the country; Melbourne is the location of circuit; | SELECT
COUNT(`circuitId`)
FROM `circuits`
WHERE
`location` = 'Adelaide' AND `country` = 'Australia' | simple |
948 | formula_1 | What are the maximum points of British constructors? | maximum points = MAX(points); British is a nationality | SELECT
MAX(`T1`.`points`)
FROM `constructorStandings` AS `T1`
INNER JOIN `constructors` AS `T2`
ON `T1`.`constructorId` = `T2`.`constructorId`
WHERE
`T2`.`nationality` = 'British' | simple |
950 | formula_1 | Please list the constructor names with 0 points at race 291. | race at 291 refers to raceID = 291; | SELECT
`T2`.`name`
FROM `constructorStandings` AS `T1`
INNER JOIN `constructors` AS `T2`
ON `T1`.`constructorId` = `T2`.`constructorId`
WHERE
`T1`.`points` = 0 AND `T1`.`raceId` = 291 | simple |
951 | formula_1 | How many Japanese constructors have 0 points in 2 races? | 2 races refers to COUNT(raceID) = 2; Japanese refers to constructors.nationality = 'Japanese'; | SELECT
COUNT(`T1`.`raceId`)
FROM `constructorStandings` AS `T1`
INNER JOIN `constructors` AS `T2`
ON `T1`.`constructorId` = `T2`.`constructorId`
WHERE
`T1`.`points` = 0 AND `T2`.`nationality` = 'Japanese'
GROUP BY
`T1`.`constructorId`
HAVING
COUNT(`raceId`) = 2 | simple |
954 | formula_1 | Please calculate the race completion percentage of Japanese drivers from 2007 to 2009. | from 2007 to 2009 refers to year between 2007 and 2009; race completion refers to time is not null; percentage = Divide(COUNT(DriverID where time is not null and year between 2007 and 2009),Count (DriverID where year between 2007 and 2009))*100; | SELECT
CAST(SUM(CASE WHEN NOT `T1`.`time` IS NULL THEN 1 ELSE 0 END) AS DOUBLE) * 100 / COUNT(`T1`.`raceId`)
FROM `results` AS `T1`
INNER JOIN `races` AS `T2`
ON `T1`.`raceId` = `T2`.`raceId`
INNER JOIN `drivers` AS `T3`
ON `T1`.`driverId` = `T3`.`driverId`
WHERE
`T3`.`nationality` = 'Japanese' AND `T2`.`year` BETWEEN 2007 AND 2009 | challenging |
955 | formula_1 | What is the average time in seconds of champion for each year, before year 1975? | only champion's finished time is represented by 'HH:MM:SS.mmm'; finished the game refers to time is not null; before year 1975 refers to year < 1975; | WITH time_in_seconds AS (SELECT T2.year, T2.raceId, T1.positionOrder, CASE WHEN T1.positionOrder = 1 THEN (CAST(SUBSTR(T1.time, 1, 1) AS FLOAT) * 3600) + (CAST(SUBSTR(T1.time, 3, 2) AS FLOAT) * 60) + CAST(SUBSTR(T1.time, 6, 2) AS FLOAT) + CAST(SUBSTR(T1.time, 9) AS FLOAT) / 1000 ELSE 0 END AS time_seconds FROM results AS T1 INNER JOIN races AS T2 ON T1.raceId = T2.raceId WHERE NOT T1.time IS NULL), champion_time AS (SELECT year, raceId, time_seconds FROM time_in_seconds WHERE positionOrder = 1) SELECT year, AVG(time_seconds) FROM champion_time WHERE year < 1975 GROUP BY year HAVING NOT AVG(time_seconds) IS NULL | challenging |
959 | formula_1 | What is the fastest lap number of the champion in 2009? | in 2009 refers to year = 2009; Only the time of the champion shows in the format of "hour: minutes: seconds.millionsecond" | SELECT
`T1`.`fastestLap`
FROM `results` AS `T1`
INNER JOIN `races` AS `T2`
ON `T1`.`raceId` = `T2`.`raceId`
WHERE
`T2`.`year` = 2009 AND `T1`.`time` LIKE '_:%:__.___' | simple |
960 | formula_1 | What is the average of fastest lap speed in the 2009 Spanish Grand Prix race? | Spanish Grand Prix is the name of race refers to name = 'Spanish Grand Prix'; average fastest lap speed refers to avg(fastestLapSpeed); | SELECT
AVG(`T1`.`fastestLapSpeed`)
FROM `results` AS `T1`
INNER JOIN `races` AS `T2`
ON `T1`.`raceId` = `T2`.`raceId`
WHERE
`T2`.`year` = 2009 AND `T2`.`name` = 'Spanish Grand Prix' | moderate |
962 | formula_1 | From 2000 to 2005, what percentage of drivers who were born before 1985 and the lap numbers were over 50? | born before 1985 refers to year(dob)<1985; in 2000 to 2005 refers to year between 2000 and 2005; percentage = Divide(COUNT(driverId where year (dob) <1985 and laps >50),COUNT(DriverID where year between 2000 and 2005) *100; | SELECT
CAST(SUM(
CASE
WHEN DATE_FORMAT(CAST(`T3`.`dob` AS DATETIME), '%Y') < '1985' AND `T1`.`laps` > 50
THEN 1
ELSE 0
END
) AS DOUBLE) * 100 / COUNT(*)
FROM `results` AS `T1`
INNER JOIN `races` AS `T2`
ON `T1`.`raceId` = `T2`.`raceId`
INNER JOIN `drivers` AS `T3`
ON `T1`.`driverId` = `T3`.`driverId`
WHERE
`T2`.`year` BETWEEN 2000 AND 2005 | challenging |
963 | formula_1 | How many French drivers who obtain the laptime less than 02:00.00? | lap time less than 02:00.00 refers to seconds < 120; | SELECT
COUNT(`T1`.`driverId`)
FROM `drivers` AS `T1`
INNER JOIN `lapTimes` AS `T2`
ON `T1`.`driverId` = `T2`.`driverId`
WHERE
`T1`.`nationality` = 'French'
AND (
CAST(SUBSTR(`T2`.`time`, 1, 2) AS SIGNED) * 60 + CAST(SUBSTR(`T2`.`time`, 4, 2) AS SIGNED) + CAST(SUBSTR(`T2`.`time`, 7, 2) AS DOUBLE) / 1000
) < 120 | moderate |
964 | formula_1 | List out the code for drivers who have nationality in American. | nationality = 'American' | SELECT `code` FROM `drivers` WHERE `Nationality` = 'American' | simple |
967 | formula_1 | State code numbers of top 3 yougest drivers. How many Netherlandic drivers among them? | youngest driver refers to Max (year(dob)); Netherlandic and Dutch refer to the same country | SELECT COUNT(*) FROM (SELECT `T1`.`nationality` FROM `drivers` AS `T1` ORDER BY `T1`.`dob` DESC LIMIT 3) AS `T3` WHERE `T3`.`nationality` = 'Dutch' | simple |
971 | formula_1 | Please state the reference name of the oldest German driver. | oldest refers to MIN(year(dob)); reference names appear in drverRef. | SELECT `driverRef` FROM `drivers` WHERE `nationality` = 'German' ORDER BY `dob` ASC LIMIT 1 | simple |
972 | formula_1 | Which drivers who were born in 1971 and has the fastest lap time on the race? Give id and code of these drivers. | born in 1971 refers to year(dob) = 1971; has the fastest lap time refers to fastestLapTime has values | SELECT
`T2`.`driverId`,
`T2`.`code`
FROM `results` AS `T1`
INNER JOIN `drivers` AS `T2`
ON `T1`.`driverId` = `T2`.`driverId`
WHERE
DATE_FORMAT(CAST(`T2`.`dob` AS DATETIME), '%Y') = '1971'
AND NOT `T1`.`fastestLapTime` IS NULL | moderate |
977 | formula_1 | From race no. 50 to 100, how many finishers have been disqualified? | disqualified refers to statusID = 2, finisher refers to time! = null; race no. refers to raceId; raceId > 50 and raceId < 100; | SELECT
SUM(CASE WHEN NOT `time` IS NULL THEN 1 ELSE 0 END)
FROM `results`
WHERE
`statusId` = 2 AND `raceID` < 100 AND `raceId` > 50 | simple |
978 | formula_1 | How many times the circuits were held in Austria? Please give their location and coordinates. | location coordinates refers to (lat,lng); Austria refers to country = 'Austria'; | SELECT DISTINCT
`location`,
`lat`,
`lng`
FROM `circuits`
WHERE
`country` = 'Austria' | simple |
981 | formula_1 | On what year did the youngest driver had his first qualifying race? Also state the name, date and time of the race. | date of birth refers to drivers.dob; The larger the birthday value, the younger the person is, and vice versa; first qualifying race refers to MIN(races.date); | SELECT
`T3`.`year`,
`T3`.`name`,
`T3`.`date`,
`T3`.`time`
FROM `qualifying` AS `T1`
INNER JOIN `drivers` AS `T2`
ON `T1`.`driverId` = `T2`.`driverId`
INNER JOIN `races` AS `T3`
ON `T1`.`raceId` = `T3`.`raceId`
WHERE
`T1`.`driverId` = (
SELECT
`driverId`
FROM `drivers`
ORDER BY
`dob` DESC
LIMIT 1
)
ORDER BY
`T3`.`date` ASC
LIMIT 1 | moderate |
988 | formula_1 | List down top 3 German drivers who has the shortest average pit stop duration and were born between 1980-1985. | Full name of the driver refers to drivers.forename and drivers.surname; born between 1980-1985 refers to 1980<= year(dob) <=1985; Average pitstop duration refers to Divide(SUM(duration),COUNT(duration)); shortest average refers to Min(avg(duration)); | SELECT
`T2`.`forename`,
`T2`.`surname`
FROM `pitStops` AS `T1`
INNER JOIN `drivers` AS `T2`
ON `T1`.`driverId` = `T2`.`driverId`
WHERE
`T2`.`nationality` = 'German'
AND DATE_FORMAT(CAST(`T2`.`dob` AS DATETIME), '%Y') BETWEEN '1980' AND '1985'
GROUP BY
`T2`.`forename`,
`T2`.`surname`
ORDER BY
AVG(`T1`.`duration`)
LIMIT 3 | challenging |
989 | formula_1 | Who is the champion of the Canadian Grand Prix in 2008? Indicate his finish time. | Only the time of the champion shows in the format of "hour: minutes: seconds.millionsecond"; | SELECT
`T1`.`time`
FROM `results` AS `T1`
INNER JOIN `races` AS `T2`
ON `T1`.`raceId` = `T2`.`raceId`
WHERE
`T2`.`name` = 'Canadian Grand Prix'
AND `T2`.`year` = 2008
AND `T1`.`time` LIKE '_:%:__.___' | moderate |
990 | formula_1 | What is the constructor reference name of the champion in the 2009 Singapore Grand Prix? Please give its website. | the time of the champion shows in the format of "minutes: seconds.millionsecond" in which Max(time); constructor reference name refers to constructorRef; website refers to url | SELECT
`T3`.`constructorRef`,
`T3`.`url`
FROM `results` AS `T1`
INNER JOIN `races` AS `T2`
ON `T1`.`raceId` = `T2`.`raceId`
INNER JOIN `constructors` AS `T3`
ON `T1`.`constructorId` = `T3`.`constructorId`
WHERE
`T2`.`name` = 'Singapore Grand Prix'
AND `T2`.`year` = 2009
AND `T1`.`time` LIKE '_:%:__.___' | challenging |
717 | superhero | Please list all the superpowers of 3-D Man. | 3-D Man refers to superhero_name = '3-D Man'; superpowers refers to power_name | SELECT `T3`.`power_name` FROM `superhero` AS `T1` INNER JOIN `hero_power` AS `T2` ON `T1`.`id` = `T2`.`hero_id` INNER JOIN `superpower` AS `T3` ON `T2`.`power_id` = `T3`.`id` WHERE `T1`.`superhero_name` = '3-D Man' | simple |
994 | formula_1 | Which constructor scored most points from Monaco Grand Prix between 1980 and 2010? List the score, name and nationality of this team. | Monaco Grand Priz refers to the race; race in year between 1980 and 2010 | SELECT
SUM(`T1`.`points`),
`T2`.`name`,
`T2`.`nationality`
FROM `constructorResults` AS `T1`
INNER JOIN `constructors` AS `T2`
ON `T1`.`constructorId` = `T2`.`constructorId`
INNER JOIN `races` AS `T3`
ON `T3`.`raceid` = `T1`.`raceid`
WHERE
`T3`.`name` = 'Monaco Grand Prix' AND `T3`.`year` BETWEEN 1980 AND 2010
GROUP BY
`T2`.`name`
ORDER BY
SUM(`T1`.`points`) DESC
LIMIT 1 | challenging |
1,001 | formula_1 | What is full name of the racer who ranked 1st in the 3rd qualifying race held in the Marina Bay Street Circuit in 2008? | Ranked 1st in the 3rd qualifying race refer to MIN(q3); 2008 is the year of race; full name of racer = forename, surname | SELECT
`T2`.`forename`,
`T2`.`surname`
FROM `qualifying` AS `T1`
INNER JOIN `drivers` AS `T2`
ON `T1`.`driverId` = `T2`.`driverId`
INNER JOIN `races` AS `T3`
ON `T1`.`raceid` = `T3`.`raceid`
WHERE
NOT `q3` IS NULL
AND `T3`.`year` = 2008
AND `T3`.`circuitId` IN (
SELECT
`circuitId`
FROM `circuits`
WHERE
`name` = 'Marina Bay Street Circuit'
)
ORDER BY
CAST(SUBSTR(`q3`, 1, INSTR(`q3`, ':') - 1) AS SIGNED) * 60 + CAST(SUBSTR(`q3`, INSTR(`q3`, ':') + 1, INSTR(`q3`, '.') - INSTR(`q3`, ':') - 1) AS DOUBLE) + CAST(SUBSTR(`q3`, INSTR(`q3`, '.') + 1) AS DOUBLE) / 1000 ASC
LIMIT 1 | challenging |
1,002 | formula_1 | As of the present, what is the full name of the youngest racer? Indicate her nationality and the name of the race to which he/she first joined. | full name refers to forename+surname; Youngest racer = MAX(dob) | SELECT `T1`.`forename`, `T1`.`surname`, `T1`.`nationality`, `T3`.`name` FROM `drivers` AS `T1` INNER JOIN `driverStandings` AS `T2` ON `T1`.`driverId` = `T2`.`driverId` INNER JOIN `races` AS `T3` ON `T2`.`raceId` = `T3`.`raceId` ORDER BY `T1`.`dob` DESC LIMIT 1 | moderate |
1,003 | formula_1 | How many accidents did the driver who had the highest number accidents in the Canadian Grand Prix have? | number of accidents refers to the number where statusid = 3; Canadian Grand Prix refers to the race of name
| SELECT
COUNT(`T1`.`driverId`)
FROM `results` AS `T1`
INNER JOIN `races` AS `T2`
ON `T1`.`raceId` = `T2`.`raceId`
INNER JOIN `status` AS `T3`
ON `T1`.`statusId` = `T3`.`statusId`
WHERE
`T3`.`statusId` = 3 AND `T2`.`name` = 'Canadian Grand Prix'
GROUP BY
`T1`.`driverId`
ORDER BY
COUNT(`T1`.`driverId`) DESC
LIMIT 1 | moderate |
1,011 | formula_1 | Which top 20 driver created the shortest lap time ever record in a Formula_1 race? Please give them full names. | shortest lap time refers to MIN(time); the time format for the shortest lap time is 'MM:SS.mmm' or 'M:SS.mmm'; full name of the driver refers to forename, surname | WITH lap_times_in_seconds AS (SELECT driverId, (CASE WHEN SUBSTR(time, 1, INSTR(time, ':') - 1) <> '' THEN CAST(SUBSTR(time, 1, INSTR(time, ':') - 1) AS FLOAT) * 60 ELSE 0 END + CASE WHEN SUBSTR(time, INSTR(time, ':') + 1, INSTR(time, '.') - INSTR(time, ':') - 1) <> '' THEN CAST(SUBSTR(time, INSTR(time, ':') + 1, INSTR(time, '.') - INSTR(time, ':') - 1) AS FLOAT) ELSE 0 END + CASE WHEN SUBSTR(time, INSTR(time, '.') + 1) <> '' THEN CAST(SUBSTR(time, INSTR(time, '.') + 1) AS FLOAT) / 1000 ELSE 0 END) AS time_in_seconds FROM lapTimes) SELECT T2.forename, T2.surname, T1.driverId FROM (SELECT driverId, MIN(time_in_seconds) AS min_time_in_seconds FROM lap_times_in_seconds GROUP BY driverId) AS T1 INNER JOIN drivers AS T2 ON T1.driverId = T2.driverId ORDER BY T1.min_time_in_seconds ASC LIMIT 20 | challenging |
1,014 | formula_1 | Please list the lap records for the circuits in Italy. | lap record means the fastest time recorded which refers to time | WITH `fastest_lap_times` AS (
SELECT
`T1`.`raceId`,
`T1`.`FastestLapTime`,
(
CAST(SUBSTR(`T1`.`FastestLapTime`, 1, INSTR(`T1`.`FastestLapTime`, ':') - 1) AS DOUBLE) * 60
) + (
CAST(SUBSTR(
`T1`.`FastestLapTime`,
INSTR(`T1`.`FastestLapTime`, ':') + 1,
INSTR(`T1`.`FastestLapTime`, '.') - INSTR(`T1`.`FastestLapTime`, ':') - 1
) AS DOUBLE)
) + (
CAST(SUBSTR(`T1`.`FastestLapTime`, INSTR(`T1`.`FastestLapTime`, '.') + 1) AS DOUBLE) / 1000
) AS `time_in_seconds`
FROM `results` AS `T1`
WHERE
NOT `T1`.`FastestLapTime` IS NULL
)
SELECT
`T1`.`FastestLapTime` AS `lap_record`
FROM `results` AS `T1`
INNER JOIN `races` AS `T2`
ON `T1`.`raceId` = `T2`.`raceId`
INNER JOIN `circuits` AS `T3`
ON `T2`.`circuitId` = `T3`.`circuitId`
INNER JOIN (
SELECT
MIN(`fastest_lap_times`.`time_in_seconds`) AS `min_time_in_seconds`
FROM `fastest_lap_times`
INNER JOIN `races` AS `T2`
ON `fastest_lap_times`.`raceId` = `T2`.`raceId`
INNER JOIN `circuits` AS `T3`
ON `T2`.`circuitId` = `T3`.`circuitId`
WHERE
`T3`.`country` = 'Italy'
) AS `T4`
ON (
CAST(SUBSTR(`T1`.`FastestLapTime`, 1, INSTR(`T1`.`FastestLapTime`, ':') - 1) AS DOUBLE) * 60
) + (
CAST(SUBSTR(
`T1`.`FastestLapTime`,
INSTR(`T1`.`FastestLapTime`, ':') + 1,
INSTR(`T1`.`FastestLapTime`, '.') - INSTR(`T1`.`FastestLapTime`, ':') - 1
) AS DOUBLE)
) + (
CAST(SUBSTR(`T1`.`FastestLapTime`, INSTR(`T1`.`FastestLapTime`, '.') + 1) AS DOUBLE) / 1000
) = `T4`.`min_time_in_seconds`
LIMIT 1 | challenging |
719 | superhero | Among the superheroes with the super power of "Super Strength", how many of them have a height of over 200cm? | super power of "Super Strength" refers to power_name = 'Super Strength'; a height of over 200cm refers to height_cm > 200 | SELECT
COUNT(`T1`.`id`)
FROM `superhero` AS `T1`
INNER JOIN `hero_power` AS `T2`
ON `T1`.`id` = `T2`.`hero_id`
INNER JOIN `superpower` AS `T3`
ON `T2`.`power_id` = `T3`.`id`
WHERE
`T3`.`power_name` = 'Super Strength' AND `T1`.`height_cm` > 200 | moderate |
723 | superhero | Among the superheroes with blue eyes, how many of them have the super power of "Agility"? | blue eyes refers to colour = 'Blue' and eye_colour_id = colour.id; super power of "Agility" refers to power_name = 'Agility' | SELECT
COUNT(`T1`.`id`)
FROM `superhero` AS `T1`
INNER JOIN `hero_power` AS `T2`
ON `T1`.`id` = `T2`.`hero_id`
INNER JOIN `superpower` AS `T3`
ON `T2`.`power_id` = `T3`.`id`
INNER JOIN `colour` AS `T4`
ON `T1`.`eye_colour_id` = `T4`.`id`
WHERE
`T3`.`power_name` = 'Agility' AND `T4`.`colour` = 'Blue' | moderate |
724 | superhero | Please list the superhero names of all the superheroes that have blue eyes and blond hair. | blue eyes refers to colour = 'Blue' and eye_colour_id = colour.id; blond hair refers to colour = 'Blond' and hair_colour_id = colour.id; super power of "Agility" refers to power_name = 'Agility' | SELECT
`T1`.`superhero_name`
FROM `superhero` AS `T1`
INNER JOIN `colour` AS `T2`
ON `T1`.`eye_colour_id` = `T2`.`id`
INNER JOIN `colour` AS `T3`
ON `T1`.`hair_colour_id` = `T3`.`id`
WHERE
`T2`.`colour` = 'Blue' AND `T3`.`colour` = 'Blond' | challenging |
726 | superhero | Rank heroes published by Marvel Comics by their height in descending order. | name refers to superhero_name; the tallest hero refers to MAX(height_cm); published by Marvel Comics refers to publisher_name = 'Marvel Comics' | SELECT
`superhero_name`,
`height_cm`,
RANK() OVER (ORDER BY `height_cm` DESC) AS `HeightRank`
FROM `superhero`
INNER JOIN `publisher`
ON `superhero`.`publisher_id` = `publisher`.`id`
WHERE
`publisher`.`publisher_name` = 'Marvel Comics' | moderate |
728 | superhero | Rank superheroes from Marvel Comics by their eye color popularity, starting with the most common color. | the superheroes from Marvel Comics refers to publisher_name = 'Marvel Comics'; most common color refers to COUNT(superhero.id) DESC; | SELECT
`colour`.`colour` AS `EyeColor`,
COUNT(`superhero`.`id`) AS `Count`,
RANK() OVER (ORDER BY COUNT(`superhero`.`id`) DESC) AS `PopularityRank`
FROM `superhero`
INNER JOIN `colour`
ON `superhero`.`eye_colour_id` = `colour`.`id`
INNER JOIN `publisher`
ON `superhero`.`publisher_id` = `publisher`.`id`
WHERE
`publisher`.`publisher_name` = 'Marvel Comics'
GROUP BY
`colour`.`colour` | moderate |
730 | superhero | List the superheroes from Marvel Comics who have the super power of 'Super Strength'. | the superheroes from Marvel Comics refers to publisher_name = 'Marvel Comics'; super power of "Super Strength" refers to power_name = 'Super Strength'; | SELECT
`superhero_name`
FROM `superhero` AS `T1`
WHERE
EXISTS(
SELECT
1
FROM `hero_power` AS `T2`
INNER JOIN `superpower` AS `T3`
ON `T2`.`power_id` = `T3`.`id`
WHERE
`T3`.`power_name` = 'Super Strength' AND `T1`.`id` = `T2`.`hero_id`
)
AND EXISTS(
SELECT
1
FROM `publisher` AS `T4`
WHERE
`T4`.`publisher_name` = 'Marvel Comics' AND `T1`.`publisher_id` = `T4`.`id`
) | challenging |
732 | superhero | Which publisher published the slowest superhero? | the slowest superhero refers to attribute_name = 'Speed' where MIN(attribute_value); publisher refers to publisher_name | SELECT
`T2`.`publisher_name`
FROM `superhero` AS `T1`
INNER JOIN `publisher` AS `T2`
ON `T1`.`publisher_id` = `T2`.`id`
INNER JOIN `hero_attribute` AS `T3`
ON `T1`.`id` = `T3`.`hero_id`
INNER JOIN `attribute` AS `T4`
ON `T3`.`attribute_id` = `T4`.`id`
WHERE
`T4`.`attribute_name` = 'Speed'
ORDER BY
`T3`.`attribute_value`
LIMIT 1 | moderate |
733 | superhero | How many gold-eyed superheroes did Marvel Comics publish? | gold-eyed refers to colour = 'Gold' where eye_colour_id = colour.id; superheroes that Marvel Comics published refers to publisher_name = 'Marvel Comics' | SELECT
COUNT(`T1`.`id`)
FROM `superhero` AS `T1`
INNER JOIN `publisher` AS `T2`
ON `T1`.`publisher_id` = `T2`.`id`
INNER JOIN `colour` AS `T3`
ON `T1`.`eye_colour_id` = `T3`.`id`
WHERE
`T2`.`publisher_name` = 'Marvel Comics' AND `T3`.`colour` = 'Gold' | moderate |
736 | superhero | Who is the dumbest superhero? | the dumbest superhero refers to MIN(attribute_value) where attribute_name = 'Intelligence' | SELECT
`T1`.`superhero_name`
FROM `superhero` AS `T1`
INNER JOIN `hero_attribute` AS `T2`
ON `T1`.`id` = `T2`.`hero_id`
INNER JOIN `attribute` AS `T3`
ON `T2`.`attribute_id` = `T3`.`id`
WHERE
`T3`.`attribute_name` = 'Intelligence'
ORDER BY
`T2`.`attribute_value`
LIMIT 1 | moderate |
737 | superhero | What is Copycat's race? | Copycat is the superhero_name; | SELECT
`T2`.`race`
FROM `superhero` AS `T1`
INNER JOIN `race` AS `T2`
ON `T1`.`race_id` = `T2`.`id`
WHERE
`T1`.`superhero_name` = 'Copycat' | simple |
738 | superhero | Which superheroes have a durability attribute value of less than 50? | durability of less than 50 refers to attribute_name = 'Durability' AND attribute_value < 50 | SELECT
`superhero_name`
FROM `superhero` AS `T1`
WHERE
EXISTS(
SELECT
1
FROM `hero_attribute` AS `T2`
INNER JOIN `attribute` AS `T3`
ON `T2`.`attribute_id` = `T3`.`id`
WHERE
`T3`.`attribute_name` = 'Durability'
AND `T2`.`attribute_value` < 50
AND `T1`.`id` = `T2`.`hero_id`
) | simple |
739 | superhero | What are the names of the superheroes with the power of death touch? | name of superheroes refers to refers to superhero_name; the power of death touch refers to power_name = 'Death Touch' | SELECT
`T1`.`superhero_name`
FROM `superhero` AS `T1`
INNER JOIN `hero_power` AS `T2`
ON `T1`.`id` = `T2`.`hero_id`
INNER JOIN `superpower` AS `T3`
ON `T2`.`power_id` = `T3`.`id`
WHERE
`T3`.`power_name` = 'Death Touch' | moderate |
740 | superhero | How many female superheroes have a strength value of 100? | female refers to gender = 'Female'; strength value of 100 refers to attribute_name = 'Strength' AND attribute_value = 100 | SELECT
COUNT(`T1`.`id`)
FROM `superhero` AS `T1`
INNER JOIN `hero_attribute` AS `T2`
ON `T1`.`id` = `T2`.`hero_id`
INNER JOIN `attribute` AS `T3`
ON `T2`.`attribute_id` = `T3`.`id`
INNER JOIN `gender` AS `T4`
ON `T1`.`gender_id` = `T4`.`id`
WHERE
`T3`.`attribute_name` = 'Strength'
AND `T2`.`attribute_value` = 100
AND `T4`.`gender` = 'Female' | moderate |
743 | superhero | What is the percentage of superheroes who act in their own self-interest or make decisions based on their own moral code? Indicate how many of the said superheroes were published by Marvel Comics. | published by Marvel Comics refers to publisher_name = 'Marvel Comics'; superheroes who act in their own self-interest or make decisions based on their own moral code refers to alignment = 'Bad'; calculation = MULTIPLY(DIVIDE(SUM(alignment = 'Bad); count(id)), 100) | SELECT
(
CAST(COUNT(*) AS DOUBLE) * 100 / (
SELECT
COUNT(*)
FROM `superhero`
)
),
CAST(SUM(CASE WHEN `T2`.`publisher_name` = 'Marvel Comics' THEN 1 ELSE 0 END) AS DOUBLE)
FROM `superhero` AS `T1`
INNER JOIN `publisher` AS `T2`
ON `T1`.`publisher_id` = `T2`.`id`
INNER JOIN `alignment` AS `T3`
ON `T3`.`id` = `T1`.`alignment_id`
WHERE
`T3`.`alignment` = 'Bad' | challenging |
744 | superhero | Between DC and Marvel Comics, which publisher has published more superheroes? Find the difference in the number of superheroes they have published. | DC refers to publisher_name = 'DC Comics'; Marvel Comics refers to publisher_name = 'Marvel Comics'; calculation = SUBTRACT(SUM(publisher_name = 'Marvel Comics'), SUM(publisher_name = 'DC Comics')) | SELECT
SUM(CASE WHEN `T2`.`publisher_name` = 'Marvel Comics' THEN 1 ELSE 0 END) - SUM(CASE WHEN `T2`.`publisher_name` = 'DC Comics' THEN 1 ELSE 0 END)
FROM `superhero` AS `T1`
INNER JOIN `publisher` AS `T2`
ON `T1`.`publisher_id` = `T2`.`id` | challenging |
745 | superhero | Give the publisher ID of Star Trek. | Star Trek is the publisher_name; | SELECT
`id`
FROM `publisher`
WHERE
`publisher_name` = 'Star Trek' | simple |
747 | superhero | What is the total number of superheroes without full name? | superheroes without full name refers to full_name IS NULL | SELECT
COUNT(`id`)
FROM `superhero`
WHERE
`full_name` IS NULL | simple |
750 | superhero | What is the average weight of all female superheroes? | female refers to gender = 'Female'; average weight refers to AVG(weight_kg) | SELECT
AVG(`T1`.`weight_kg`)
FROM `superhero` AS `T1`
INNER JOIN `gender` AS `T2`
ON `T1`.`gender_id` = `T2`.`id`
WHERE
`T2`.`gender` = 'Female' | simple |
751 | superhero | List down at least five superpowers of male superheroes. | male refers to gender = 'Male'; superpowers refers to power_name; | SELECT
`T3`.`power_name`
FROM `superhero` AS `T1`
INNER JOIN `hero_power` AS `T2`
ON `T1`.`id` = `T2`.`hero_id`
INNER JOIN `superpower` AS `T3`
ON `T3`.`id` = `T2`.`power_id`
INNER JOIN `gender` AS `T4`
ON `T4`.`id` = `T1`.`gender_id`
WHERE
`T4`.`gender` = 'Male'
LIMIT 5 | moderate |
753 | superhero | Among the superheroes with height from 170 to 190, list the names of the superheroes with no eye color. | height from 170 to 190 refers to height_cm BETWEEN 170 AND 190; no eye color refers to colour = 'No Colour' | SELECT DISTINCT
`T1`.`superhero_name`
FROM `superhero` AS `T1`
INNER JOIN `colour` AS `T2`
ON `T1`.`eye_colour_id` = `T2`.`id`
WHERE
`T1`.`height_cm` BETWEEN 170 AND 190 AND `T2`.`colour` = 'No Colour' | moderate |
758 | superhero | Provide the hair colour of the human superhero who is 185 cm tall. | 185 cm tall refers to height_cm = 185; human superhero refers to race = 'human'; hair colour refers to colour where hair_colour_id = colour.id; | SELECT DISTINCT
`T3`.`colour`
FROM `superhero` AS `T1`
INNER JOIN `race` AS `T2`
ON `T1`.`race_id` = `T2`.`id`
INNER JOIN `colour` AS `T3`
ON `T1`.`hair_colour_id` = `T3`.`id`
WHERE
`T1`.`height_cm` = 185 AND `T2`.`race` = 'Human' | moderate |
760 | superhero | In superheroes with height between 150 to 180, what is the percentage of heroes published by Marvel Comics? | height between 150 to 180 refers to height_cm BETWEEN 150 AND 180; heroes published by Marvel Comics refers to publisher_name = 'Marvel Comics'; calculation = MULTIPLY(DIVIDE(SUM(publisher.id = 13)), COUNT(publisher.id), 100) | SELECT
CAST(COUNT(CASE WHEN `T2`.`publisher_name` = 'Marvel Comics' THEN 1 ELSE NULL END) AS DOUBLE) * 100 / COUNT(`T1`.`id`)
FROM `superhero` AS `T1`
INNER JOIN `publisher` AS `T2`
ON `T1`.`publisher_id` = `T2`.`id`
WHERE
`T1`.`height_cm` BETWEEN 150 AND 180 | challenging |
761 | superhero | Among the male superheroes, list the super hero names of superheroes with weight greater than the 79% average weight of all superheroes. | super hero names refers to superhero_name;male superheros refers to gender = 'Male';Calculation = weight_kg > MULTIPLY(AVG(weight_kg), 0.79) | SELECT
`T1`.`superhero_name`
FROM `superhero` AS `T1`
INNER JOIN `gender` AS `T2`
ON `T1`.`gender_id` = `T2`.`id`
WHERE
`T2`.`gender` = 'Male'
AND `T1`.`weight_kg` * 100 > (
SELECT
AVG(`weight_kg`)
FROM `superhero`
) * 79 | moderate |
764 | superhero | What are the superpowers of heroes with ID 1? | superpowers refers to power_name; heroes with ID 1 refers to hero_id = 1; | SELECT DISTINCT
`T2`.`power_name`
FROM `hero_power` AS `T1`
INNER JOIN `superpower` AS `T2`
ON `T1`.`power_id` = `T2`.`id`
WHERE
`T1`.`hero_id` = 1 | simple |
765 | superhero | How many heroes have stealth power? | stealth power refers to power_name = 'Stealth'; | SELECT
COUNT(`T1`.`hero_id`)
FROM `hero_power` AS `T1`
INNER JOIN `superpower` AS `T2`
ON `T1`.`power_id` = `T2`.`id`
WHERE
`T2`.`power_name` = 'Stealth' | simple |
766 | superhero | What is the hero's full name with the highest attribute in strength? | highest attribute in strength refers to MAX(attribute_value) WHERE attribute_name = 'strength'; | SELECT `T1`.`full_name` FROM `superhero` AS `T1` INNER JOIN `hero_attribute` AS `T2` ON `T1`.`id` = `T2`.`hero_id` INNER JOIN `attribute` AS `T3` ON `T2`.`attribute_id` = `T3`.`id` WHERE `T3`.`attribute_name` = 'Strength' ORDER BY `T2`.`attribute_value` DESC LIMIT 1 | moderate |
769 | superhero | Which superhero has the most durability published by Dark Horse Comics? | which superhero refers to superhero_name; most durability refers to MAX(attribute_value) WHERE attribute_name = 'durability'; published by Dark Horse Comics refers to publisher_name = 'Dark Horse Comics'; | SELECT
`T1`.`superhero_name`
FROM `superhero` AS `T1`
INNER JOIN `hero_attribute` AS `T2`
ON `T1`.`id` = `T2`.`hero_id`
INNER JOIN `attribute` AS `T3`
ON `T3`.`id` = `T2`.`attribute_id`
INNER JOIN `publisher` AS `T4`
ON `T4`.`id` = `T1`.`publisher_id`
WHERE
`T4`.`publisher_name` = 'Dark Horse Comics'
AND `T3`.`attribute_name` = 'Durability'
ORDER BY
`T2`.`attribute_value` DESC
LIMIT 1 | challenging |
772 | superhero | List the eyes, hair and skin colour of all female superheroes published by Dark Horse Comics. | eyes refers to eye_colour_id; hair refers to hair_colour_id; skin colour refers to skin_colour_id; female superheroes refers to gender = 'Female'; published by Dark Horse Comics refers to publisher_name = 'Dark Horse Comics'; | SELECT
`T1`.`eye_colour_id`,
`T1`.`hair_colour_id`,
`T1`.`skin_colour_id`
FROM `superhero` AS `T1`
INNER JOIN `publisher` AS `T2`
ON `T2`.`id` = `T1`.`publisher_id`
INNER JOIN `gender` AS `T3`
ON `T3`.`id` = `T1`.`gender_id`
WHERE
`T2`.`publisher_name` = 'Dark Horse Comics' AND `T3`.`gender` = 'Female' | challenging |
773 | superhero | Which superhero has the same eyes, hair and skin colour? Indicate the publisher of the superhero. | which superhero refers to superhero_name; the same eyes, hair and skin colour refers to hair_colour_id = skin_colour_id AND hair_colour_id = eye_colour_id; publisher refers to publisher_name; | SELECT
`T1`.`superhero_name`,
`T2`.`publisher_name`
FROM `superhero` AS `T1`
INNER JOIN `publisher` AS `T2`
ON `T1`.`publisher_id` = `T2`.`id`
WHERE
`T1`.`eye_colour_id` = `T1`.`hair_colour_id`
AND `T1`.`eye_colour_id` = `T1`.`skin_colour_id` | challenging |
775 | superhero | What is the percentage of blue female superheroes among all female superheroes? | percentage = MULTIPLY(DIVIDE(SUM(colour = 'Blue' WHERE gender = 'Female'), COUNT(gender = 'Female')), 100); blue refers to the color = 'Blue' WHERE skin_colour_id = colour.id; female refers to gender = 'Female'; | SELECT
CAST(COUNT(CASE WHEN `T3`.`colour` = 'Blue' THEN `T1`.`id` ELSE NULL END) AS DOUBLE) * 100 / COUNT(`T1`.`id`)
FROM `superhero` AS `T1`
INNER JOIN `gender` AS `T2`
ON `T1`.`gender_id` = `T2`.`id`
INNER JOIN `colour` AS `T3`
ON `T1`.`skin_colour_id` = `T3`.`id`
WHERE
`T2`.`gender` = 'Female' | challenging |
779 | superhero | How many powers does Amazo hero have? | Amazo hero refers to superhero_name = 'Amazo'; | SELECT
COUNT(`T1`.`power_id`)
FROM `hero_power` AS `T1`
INNER JOIN `superhero` AS `T2`
ON `T1`.`hero_id` = `T2`.`id`
WHERE
`T2`.`superhero_name` = 'Amazo' | simple |
781 | superhero | Provide the heights of the heroes whose eye colours are amber. | heights of the heroes refers to height_cm; eye colours are amber refers to colour.colour = 'Amber' WHERE eye_colour_id = colour.id; | SELECT
`T1`.`height_cm`
FROM `superhero` AS `T1`
INNER JOIN `colour` AS `T2`
ON `T1`.`eye_colour_id` = `T2`.`id`
WHERE
`T2`.`colour` = 'Amber' | simple |
782 | superhero | List the heroes' names whose eyes and hair colours are both black. | heroes' names refers to superhero_name; eyes and hair colours are both black refers to eye_colour_id AND hair_colour_id WHERE colour.colour = 'Black'; | SELECT
`T1`.`superhero_name`
FROM `superhero` AS `T1`
INNER JOIN `colour` AS `T2`
ON `T1`.`eye_colour_id` = `T2`.`id` AND `T1`.`hair_colour_id` = `T2`.`id`
WHERE
`T2`.`colour` = 'Black' | moderate |
785 | superhero | Describe the names of neutral alignment superheroes. | names of superheroes refers to superhero_name; neutral alignment refers to alignment = 'Neutral'; | SELECT
`T1`.`superhero_name`
FROM `superhero` AS `T1`
INNER JOIN `alignment` AS `T2`
ON `T1`.`alignment_id` = `T2`.`id`
WHERE
`T2`.`alignment` = 'Neutral' | simple |
786 | superhero | How many heroes have the highest attribute value in strength? | highest attribute value in strength refers to MAX(attribute_value) WHERE attribute_name = 'Strength'; | SELECT
COUNT(`T1`.`hero_id`)
FROM `hero_attribute` AS `T1`
INNER JOIN `attribute` AS `T2`
ON `T1`.`attribute_id` = `T2`.`id`
WHERE
`T2`.`attribute_name` = 'Strength'
AND `T1`.`attribute_value` = (
SELECT
MAX(`attribute_value`)
FROM `hero_attribute`
) | moderate |
788 | superhero | How many percent of female heroes were published by Marvel Comics? | percent = MULTIPLY(DIVIDE(SUM(gender = 'Female' WHERE publisher_name = 'Marvel Comics'), COUNT(publisher_name = 'Marvel Comics')), 100); female heroes refers to gender = 'Female'; Marvel Comics refers to publisher_name = 'Marvel Comics'; | SELECT
CAST(COUNT(CASE WHEN `T2`.`publisher_name` = 'Marvel Comics' AND `T3`.`gender` = 'Female' THEN 1 ELSE NULL END) AS DOUBLE) * 100 / COUNT(CASE WHEN `T2`.`publisher_name` = 'Marvel Comics' THEN 1 ELSE NULL END)
FROM `superhero` AS `T1`
INNER JOIN `publisher` AS `T2`
ON `T1`.`publisher_id` = `T2`.`id`
INNER JOIN `gender` AS `T3`
ON `T1`.`gender_id` = `T3`.`id`
| challenging |
790 | superhero | Calculate the difference between Emil Blonsky's weight and Charles Chandler's weight. | difference = SUBTRACT(SUM(weight_kg WHERE full_name = 'Emil Blonsky'), SUM(weight_kg WHERE full_name = 'Charles Chandler')); Emil Blonsky is the full name of superhero; Charles Chandler is the full name of superhero; | SELECT
(
SELECT
`weight_kg`
FROM `superhero`
WHERE
`full_name` LIKE 'Emil Blonsky'
) - (
SELECT
`weight_kg`
FROM `superhero`
WHERE
`full_name` LIKE 'Charles Chandler'
) AS `CALCULATE` | moderate |
791 | superhero | Calculate the average height for all superhero. | average = DIVIDE(SUM(height_cm), COUNT(all heros)); | SELECT
CAST(SUM(`height_cm`) AS DOUBLE) / COUNT(`id`)
FROM `superhero` | simple |
792 | superhero | What is Abomination's superpower? | Abomination refers to superhero_name = 'Abomination'; superpower refers to power_name; | SELECT
`T3`.`power_name`
FROM `superhero` AS `T1`
INNER JOIN `hero_power` AS `T2`
ON `T1`.`id` = `T2`.`hero_id`
INNER JOIN `superpower` AS `T3`
ON `T2`.`power_id` = `T3`.`id`
WHERE
`T1`.`superhero_name` = 'Abomination' | simple |
794 | superhero | Which hero was the fastest? | which hero refers to superhero_name; fastest refers to MAX(attribute_value) WHERE attribute_name = 'Speed'; | SELECT `T1`.`superhero_name` FROM `superhero` AS `T1` INNER JOIN `hero_attribute` AS `T2` ON `T1`.`id` = `T2`.`hero_id` INNER JOIN `attribute` AS `T3` ON `T2`.`attribute_id` = `T3`.`id`WHERE `T3`.`attribute_name` = 'Speed' AND `T2`.`attribute_value` = (SELECT MAX(`attribute_value`) FROM `hero_attribute` AS `T2b` WHERE `T2b`.`attribute_id` = `T3`.`id` ) LIMIT 1 | moderate |
796 | superhero | State all of 3-D Man's attributes along with their values. | 3-D Man is the superhero_name. attributes refers to attribute_name; values refers to attribute_value; | SELECT
`T3`.`attribute_name`,
`T2`.`attribute_value`
FROM `superhero` AS `T1`
INNER JOIN `hero_attribute` AS `T2`
ON `T1`.`id` = `T2`.`hero_id`
INNER JOIN `attribute` AS `T3`
ON `T2`.`attribute_id` = `T3`.`id`
WHERE
`T1`.`superhero_name` = '3-D Man' | moderate |
797 | superhero | Which superheroes have blue eyes with brown hair? | which superheroes refers to superhero_name; blue eyes refers to color = 'Blue' and color.id = eye_colour_id; brown hair refers to color = 'Brown' and color.id = hair_colour_id; | SELECT
`T1`.`superhero_name`
FROM `superhero` AS `T1`
INNER JOIN `colour` AS `T2`
ON `T1`.`eye_colour_id` = `T2`.`id`
INNER JOIN `colour` AS `T3`
ON `T1`.`hair_colour_id` = `T3`.`id`
WHERE
`T2`.`colour` = 'Blue' AND `T3`.`colour` = 'Brown' | moderate |
798 | superhero | What is the publisher for Hawkman, Karate Kid and Speedy? | publisher refers to publisher_name; Hawkman refers to superhero_name = 'Hawkman'; Karate Kid refers to superhero_name = 'Karate Kid'; Speedy refers to superhero_name = 'Speedy'; | SELECT
`T2`.`publisher_name`
FROM `superhero` AS `T1`
INNER JOIN `publisher` AS `T2`
ON `T1`.`publisher_id` = `T2`.`id`
WHERE
`T1`.`superhero_name` IN ('Hawkman', 'Karate Kid', 'Speedy') | moderate |
800 | superhero | Calculate the percentage of superheroes with blue eyes. | percentage = MULTIPLY(DIVIDE(SUM(superhero_name WHERE color = 'Blue'), COUNT(superhero_name)), 100.0); blue eyes refers to color = 'Blue' and color.id = eye_colour_id = 7; | SELECT
CAST(COUNT(CASE WHEN `T2`.`colour` = 'Blue' THEN 1 ELSE NULL END) AS DOUBLE) * 100 / COUNT(`T1`.`id`)
FROM `superhero` AS `T1`
INNER JOIN `colour` AS `T2`
ON `T1`.`eye_colour_id` = `T2`.`id` | moderate |
801 | superhero | Find the ratio between male superheroes and female superheroes. | ratio = DIVIDE(SUM(gender_id = 1) / SUM(gender_id = 2)); male superheroes refers to gender = 'Female'; female superheroes refers to gender = 'Male'; | SELECT
CAST(COUNT(CASE WHEN `T2`.`gender` = 'Male' THEN `T1`.`id` ELSE NULL END) AS DOUBLE) / COUNT(CASE WHEN `T2`.`gender` = 'Female' THEN `T1`.`id` ELSE NULL END)
FROM `superhero` AS `T1`
INNER JOIN `gender` AS `T2`
ON `T1`.`gender_id` = `T2`.`id` | moderate |
806 | superhero | Provide the eye colour of the superhero who has Karen Beecher-Duncan as their full name. | eye colour refers to colour.colour where eye_colour_id = colour.id; Karen Beecher-Duncan is the full name of superhero; | SELECT
`T2`.`colour`
FROM `superhero` AS `T1`
INNER JOIN `colour` AS `T2`
ON `T1`.`eye_colour_id` = `T2`.`id`
WHERE
`T1`.`full_name` = 'Karen Beecher-Duncan' | simple |
819 | superhero | In superheroes with missing weight data, calculate the difference between the number of superheroes with blue eyes and no eye color. | missing weight data refers to weight_kg = 0 OR T1.weight_kg = NULL; difference = SUBTRACT(SUM(colour.id = 7), SUM(colour.id = 1)); blue eyes refers to eye_colour_id WHERE colour.id = 7; no eye color refers to eye_colour_id WHERE colour.id = 1; | SELECT
SUM(CASE WHEN `T2`.`id` = 7 THEN 1 ELSE 0 END) - SUM(CASE WHEN `T2`.`id` = 1 THEN 1 ELSE 0 END)
FROM `superhero` AS `T1`
INNER JOIN `colour` AS `T2`
ON `T1`.`eye_colour_id` = `T2`.`id`
WHERE
`T1`.`weight_kg` = 0 OR `T1`.`weight_kg` IS NULL | challenging |
822 | superhero | How many green-skinned villains are there in the superhero universe? | green-skinned refers to colour.colour = 'Green' WHERE skin_colour_id = colour.id; villains refers to alignment = 'Bad'; | SELECT
COUNT(`T1`.`id`)
FROM `superhero` AS `T1`
INNER JOIN `alignment` AS `T2`
ON `T1`.`alignment_id` = `T2`.`id`
INNER JOIN `colour` AS `T3`
ON `T1`.`skin_colour_id` = `T3`.`id`
WHERE
`T2`.`alignment` = 'Bad' AND `T3`.`colour` = 'Green' | moderate |
824 | superhero | Identify superheroes who can control wind and list their names in alphabetical order. | superheroes refers to superhero_name; can control wind refers to power_name = 'Wind Control'; | SELECT
`T1`.`superhero_name`
FROM `superhero` AS `T1`
INNER JOIN `hero_power` AS `T2`
ON `T1`.`id` = `T2`.`hero_id`
INNER JOIN `superpower` AS `T3`
ON `T2`.`power_id` = `T3`.`id`
WHERE
`T3`.`power_name` = 'Wind Control'
ORDER BY
`T1`.`superhero_name` | moderate |
825 | superhero | Identify the gender of the superhero who has the ability of Phoenix Force. | ability of Phoenix Force refers to power_name = 'Phoenix Force'; | SELECT
`T4`.`gender`
FROM `superhero` AS `T1`
INNER JOIN `hero_power` AS `T2`
ON `T1`.`id` = `T2`.`hero_id`
INNER JOIN `superpower` AS `T3`
ON `T2`.`power_id` = `T3`.`id`
INNER JOIN `gender` AS `T4`
ON `T1`.`gender_id` = `T4`.`id`
WHERE
`T3`.`power_name` = 'Phoenix Force' | moderate |
829 | superhero | Which publisher created more superheroes: DC or Marvel Comics? Find the difference in the number of superheroes. | DC refers to publisher_name = 'DC Comics'; Marvel Comics refers to publisher_name = 'Marvel Comics'; difference = SUBTRACT(SUM(publisher_name = 'DC Comics'), SUM(publisher_name = 'Marvel Comics')); | SELECT
SUM(CASE WHEN `T2`.`publisher_name` = 'DC Comics' THEN 1 ELSE 0 END) - SUM(CASE WHEN `T2`.`publisher_name` = 'Marvel Comics' THEN 1 ELSE 0 END)
FROM `superhero` AS `T1`
INNER JOIN `publisher` AS `T2`
ON `T1`.`publisher_id` = `T2`.`id` | challenging |
531 | codebase_community | Which user has a higher reputation, Harlan or Jarrod Dixon? | "Harlan" and "Jarrod Dixon" are both DisplayName; highest reputation refers to Max(Reputation) | SELECT
`DisplayName`
FROM `users`
WHERE
`DisplayName` IN ('Harlan', 'Jarrod Dixon')
AND `Reputation` = (
SELECT
MAX(`Reputation`)
FROM `users`
WHERE
`DisplayName` IN ('Harlan', 'Jarrod Dixon')
) | simple |
532 | codebase_community | Please list the display names of all the users whose accounts were created in the year 2011. | account created in the year 2011 refers to year(CreationDate) = 2011 | SELECT
`DisplayName`
FROM `users`
WHERE
DATE_FORMAT(CAST(`CreationDate` AS DATETIME), '%Y') = '2011' | simple |
533 | codebase_community | How many users last accessed the website after 2014/9/1? | last accessed after 2014/9/1 refers to LastAccessDate > '2014-09-01' | SELECT
COUNT(`Id`)
FROM `users`
WHERE
DATE(`LastAccessDate`) > '2014-09-01' | simple |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.