Database: race_track

Question: Show names and seatings, ordered by seating for all tracks opened after 2000.
SQL: SELECT name ,  seating FROM track WHERE year_opened  >  2000 ORDER BY seating

Question: What is the name, location and seating for the most recently opened track?
SQL: SELECT name ,  LOCATION ,  seating FROM track ORDER BY year_opened DESC LIMIT 1

Question: What is the minimum, maximum, and average seating for all tracks.
SQL: SELECT min(seating) ,  max(seating) ,  avg(seating) FROM track

Question: Show the name, location, open year for all tracks with a seating higher than the average.
SQL: SELECT name ,  LOCATION ,  year_opened FROM track WHERE seating  >  (SELECT avg(seating) FROM track)

Question: What is the race class with most number of races.
SQL: SELECT CLASS FROM race GROUP BY CLASS ORDER BY count(*) DESC LIMIT 1

Question: List the race class with at least two races.
SQL: SELECT CLASS FROM race GROUP BY CLASS HAVING count(*)  >=  2

Question: What are the names for tracks without a race in class 'GT'.
SQL: SELECT name FROM track EXCEPT SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id  =  T2.track_id WHERE T1.class  =  'GT'

Question: Show all track names that have had no races.
SQL: SELECT name FROM track WHERE track_id NOT IN (SELECT track_id FROM race)

Question: Show the name of track and the number of races in each track.
SQL: SELECT T2.name ,  count(*) FROM race AS T1 JOIN track AS T2 ON T1.track_id  =  T2.track_id GROUP BY T1.track_id

Question: Show the name of track with most number of races.
SQL: 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

Question: Show the name and location of track with 1 race.
SQL: SELECT T2.name ,  T2.location FROM race AS T1 JOIN track AS T2 ON T1.track_id  =  T2.track_id GROUP BY T1.track_id HAVING count(*)  =  1