CREATE TABLE circuits (
    circuitId NUMBER PRIMARY KEY,
    circuitRef TEXT,
    name TEXT,
    location TEXT,
    country TEXT,
    lat NUMBER,
    lng NUMBER,
    alt NUMBER,
    url TEXT
);
CREATE TABLE races (
    raceId NUMBER PRIMARY KEY,
    year NUMBER,
    round NUMBER,
    circuitId NUMBER,
    name TEXT,
    date TEXT,
    time TEXT,
    url TEXT,
    FOREIGN KEY ("circuitId") REFERENCES circuits("circuitId")
);
CREATE TABLE drivers (
    driverId NUMBER PRIMARY KEY,
    driverRef TEXT,
    number NUMBER,
    code TEXT,
    forename TEXT,
    surname TEXT,
    dob TEXT,
    nationality TEXT,
    url TEXT
);
CREATE TABLE status (
    statusId NUMBER PRIMARY KEY,
    status TEXT
);
CREATE TABLE seasons (
    year NUMBER PRIMARY KEY,
    url TEXT
);
CREATE TABLE constructors (
    constructorId NUMBER PRIMARY KEY,
    constructorRef TEXT,
    name TEXT,
    nationality TEXT,
    url TEXT
);
CREATE TABLE constructorStandings (
    constructorStandingsId NUMBER PRIMARY KEY,
    raceId NUMBER,
    constructorId NUMBER,
    points NUMBER,
    position NUMBER,
    positionText TEXT,
    wins NUMBER,
    FOREIGN KEY ("raceId") REFERENCES races("raceId"),
    FOREIGN KEY ("constructorId") REFERENCES constructors("constructorId")
);
CREATE TABLE results (
    resultId NUMBER PRIMARY KEY,
    raceId NUMBER,
    driverId NUMBER,
    constructorId NUMBER,
    number NUMBER,
    grid NUMBER,
    position NUMBER,
    positionText TEXT,
    positionOrder NUMBER,
    points NUMBER,
    laps NUMBER,
    time TEXT,
    milliseconds NUMBER,
    fastestLap NUMBER,
    rank NUMBER,
    fastestLapTime TEXT,
    fastestLapSpeed TEXT,
    statusId NUMBER,
    FOREIGN KEY ("driverId") REFERENCES drivers("driverId"),
    FOREIGN KEY ("raceId") REFERENCES races("raceId"),
    FOREIGN KEY ("constructorId") REFERENCES constructors("constructorId")
);
CREATE TABLE driverStandings (
    driverStandingsId NUMBER PRIMARY KEY,
    raceId NUMBER,
    driverId NUMBER,
    points NUMBER,
    position NUMBER,
    positionText TEXT,
    wins NUMBER,
    FOREIGN KEY ("driverId") REFERENCES drivers("driverId"),
    FOREIGN KEY ("raceId") REFERENCES races("raceId")
);
CREATE TABLE constructorResults (
    constructorResultsId NUMBER PRIMARY KEY,
    raceId NUMBER,
    constructorId NUMBER,
    points NUMBER,
    status NUMBER,
    FOREIGN KEY ("raceId") REFERENCES races("raceId"),
    FOREIGN KEY ("constructorId") REFERENCES constructors("constructorId")
);
CREATE TABLE qualifying (
    qualifyId NUMBER PRIMARY KEY,
    raceId NUMBER,
    driverId NUMBER,
    constructorId NUMBER,
    number NUMBER,
    position NUMBER,
    q1 TEXT,
    q2 TEXT,
    q3 TEXT,
    FOREIGN KEY ("driverId") REFERENCES drivers("driverId"),
    FOREIGN KEY ("raceId") REFERENCES races("raceId"),
    FOREIGN KEY ("constructorId") REFERENCES constructors("constructorId")
);
CREATE TABLE pitStops (
    raceId NUMBER PRIMARY KEY,
    driverId NUMBER,
    stop NUMBER,
    lap NUMBER,
    time TEXT,
    duration TEXT,
    milliseconds NUMBER,
    FOREIGN KEY ("driverId") REFERENCES drivers("driverId"),
    FOREIGN KEY ("raceId") REFERENCES races("raceId")
);
CREATE TABLE lapTimes (
    raceId NUMBER PRIMARY KEY,
    driverId NUMBER,
    lap NUMBER,
    position NUMBER,
    time TEXT,
    milliseconds NUMBER,
    FOREIGN KEY ("driverId") REFERENCES drivers("driverId"),
    FOREIGN KEY ("raceId") REFERENCES races("raceId")
);

Question: Give me a list of names and years of races that had any driver whose forename is Lewis?
SQL: SELECT T2.name ,  T2.year FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T1.driverid = T3.driverid WHERE T3.forename = "Lewis"

Question: What are the names and years of all races that had a driver with the last name Lewis?
SQL: SELECT T2.name ,  T2.year FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T1.driverid = T3.driverid WHERE T3.forename = "Lewis"

Question: Find the forename and surname of drivers whose nationality is German?
SQL: SELECT forename ,  surname FROM drivers WHERE nationality = "German"

Question: What is the first and last name of all the German drivers?
SQL: SELECT forename ,  surname FROM drivers WHERE nationality = "German"

Question: Find the id and forenames of drivers who participated both the races with name Australian Grand Prix and the races with name Chinese Grand Prix?
SQL: SELECT T2.driverid ,  T3.forename 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" INTERSECT SELECT T2.driverid ,  T3.forename 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: What is the id and first name of all the drivers who participated in the Australian Grand Prix and the Chinese Grand Prix?
SQL: SELECT T2.driverid ,  T3.forename 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" INTERSECT SELECT T2.driverid ,  T3.forename 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: 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: What are the first and last names of all drivers who participated in the Australian Grand Prix but not the 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: What are all the different first names of the drivers who are in position 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 first names of the different 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: For each nationality, how many different constructors are there?
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