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 the name of track with most number of races.
assistant
SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id ORDER BY count(*) DESC LIMIT 1
human
Show the race class and number of races in each class.
assistant
SELECT CLASS , count(*) FROM race GROUP BY CLASS
human
What are the distinct classes that races can have?
assistant
SELECT DISTINCT CLASS FROM race
human
List the race class with at least two races.
assistant
SELECT CLASS FROM race GROUP BY CLASS HAVING count(*) >= 2
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
How many races are there?
assistant
SELECT COUNT( * ) FROM race ;