human
Schema:
race (Race_ID, Name, Class, Date, Track_ID)
track (Track_ID, Name, Location, Seating, Year_Opened)
Please answer with SQL.
assistant
Sure, I understand.
human
Show name, class, and date for all races.
assistant
SELECT name , CLASS , date FROM race
human
How many races are there?
assistant
SELECT count(*) FROM race
human
What are the distinct classes that races can have?
assistant
SELECT DISTINCT CLASS FROM race
human
Show the race class and number of races in each class.
assistant
SELECT CLASS , count(*) FROM race GROUP BY CLASS
human
What is the race class with most number of races.
assistant
SELECT CLASS FROM race GROUP BY CLASS ORDER BY count(*) DESC LIMIT 1
human
List the race class with at least two races.
assistant
SELECT CLASS FROM race GROUP BY CLASS HAVING COUNT( * ) >= 2 ;