Database: formula_1

Question: What are the forenames and surnames of drivers who participated in the races named Australian Grand Prix but not the races named Chinese Grand Prix?
SQL: SELECT T3.forename ,  T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" EXCEPT SELECT T3.forename ,  T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix"

Question: Find all the forenames of distinct drivers who was in position 1 as standing and won?
SQL: SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1

Question: Find all the forenames of distinct drivers who won in position 1 as driver standing and had more than 20 points?
SQL: SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1 AND T2.points > 20

Question: What are the numbers of constructors for different nationalities?
SQL: SELECT count(*) ,  nationality FROM constructors GROUP BY nationality

Question: What are the numbers of races for each constructor id?
SQL: SELECT count(*) ,  constructorid FROM constructorStandings GROUP BY constructorid

Question: What are the names of races that were held after 2017 and the circuits were in the country of Spain?
SQL: SELECT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2017

Question: What are the unique names of races that held after 2000 and the circuits were in Spain?
SQL: SELECT DISTINCT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2000

Question: Find the distinct driver id and the stop number of all drivers that have a shorter pit stop duration than some drivers in the race with id 841.
SQL: SELECT DISTINCT driverid ,  STOP FROM pitstops WHERE duration  <  (SELECT max(duration) FROM pitstops WHERE raceid  =  841)

Question: Find the distinct driver id of all drivers that have a longer stop duration than some drivers in the race whose id is 841?
SQL: SELECT DISTINCT driverid ,  STOP FROM pitstops WHERE duration  >  (SELECT min(duration) FROM pitstops WHERE raceid  =  841)

Question: List the forenames of all distinct drivers in alphabetical order?
SQL: SELECT DISTINCT forename FROM drivers ORDER BY forename ASC

Question: List the names of all distinct races in reversed  lexicographic order?
SQL: SELECT DISTINCT name FROM races ORDER BY name DESC

Question: What are the names of races held between 2009 and 2011?
SQL: SELECT name FROM races WHERE YEAR BETWEEN 2009 AND 2011

Question: What are the names of races held after 12:00:00 or before 09:00:00?
SQL: SELECT name FROM races WHERE TIME > "12:00:00" OR TIME < "09:00:00"