In: Computer Science
Need SQL commands for these questions based on the bowling league database; When was the first tournament date and where was it played? What are the number of tournaments per location?
Here Taking a sample data as shown below.
TOURNAMENTS is a table which has these list of attributes ID, NAME, DAY, LOCATION.
To find the fist tournament date and location, we need to sort with respect to the day and the top one will be the first tournament. So here we are using ORDER BY DAY as well as the LIMIT as 1
SELECT * FROM TOURNAMENTS T ORDER BY T.DAY LIMIT
1;
To find the number of tournaments per location, Need to group
those records based on the location. So here using the
GROUP BY
SELECT T.LOCATION, COUNT(*) AS NO_TOURNAMENT FROM
TOURNAMENTS T GROUP BY T.LOCATION;