human
Schema:
circuits (circuitId, circuitRef, name, location, country, lat, lng, alt, url)
races (raceId, year, round, circuitId, name, date, time, url)
drivers (driverId, driverRef, number, code, forename, surname, dob, nationality, url)
status (statusId, status)
seasons (year, url)
constructors (constructorId, constructorRef, name, nationality, url)
constructorStandings (constructorStandingsId, raceId, constructorId, points, position, positionText, wins)
results (resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId)
driverStandings (driverStandingsId, raceId, driverId, points, position, positionText, wins)
constructorResults (constructorResultsId, raceId, constructorId, points, status)
qualifying (qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3)
pitStops (raceId, driverId, stop, lap, time, duration, milliseconds)
lapTimes (raceId, driverId, lap, position, time, milliseconds)
Please answer with SQL.
assistant
Sure, I understand.
human
What are the names of races held after 12:00:00 or before 09:00:00?
assistant
SELECT name FROM races WHERE TIME > '12:00:00' OR TIME < '09:00:00'
human
Find the names of all races held in 2017.
assistant
SELECT name FROM races WHERE YEAR = 2017
human
Find the distinct names of all races held between 2014 and 2017?
assistant
SELECT DISTINCT name FROM races WHERE YEAR BETWEEN 2014 AND 2017
human
What are the names of races held between 2009 and 2011?
assistant
SELECT name FROM races WHERE YEAR BETWEEN 2009 AND 2011
human
What is the name of the race held most recently?
assistant
SELECT name FROM races ORDER BY date DESC LIMIT 1
human
What is the name and date of the race that occurred most recently?
assistant
SELECT name , date FROM races ORDER BY date DESC LIMIT 1 ;