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
What are the names of the tracks for each race?
assistant
SELECT T2.name , T1.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id;
human
How many races for the track name 'Auto Club Speedway'?
assistant
SELECT T2.name , T1.name , COUNT( * ) FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id having T2.name = 'Auto Club Speedway';
human
For each track name, how many races are there?
assistant
SELECT T2.name , COUNT( * ) FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id ;