Mid Level SQL Practice Grounds
Last modified: December 09, 2019
You’ve covered the majority of the main use cases of SQL! You know the stuff, but now you’ve got some practicing to do to become really fluent and skilled at it. Here we’ve constructed a large list of challenges to give you that practice. If you forgot the rules of our practice playgrounds you can review them in the Basic SQL Practice page.
Good luck!
Q. Fetch the the names of the tracks with the word ‘wild’ in it, regardless of case
references: operators
Q. How many unique composers are there in the tracks table with the genre_id of 1.
references:
Q. What is the average length for tracks with genre_ids of either 5, 7 or 10?
references: operators aggregate
Q. A list of the number of tracks grouped by genre_id and then album_id with the column order of genre_id, album_id and count.
references: group-by
Q. Take the above query, but order the album_id in descending order, keeping genre_id odered the same
Q. Take the above query with the same ordering but group by album_id and then genre_id and change the order of the results to reflect that switch.
Q. There is a foreign key customer_id that relates invoices to the customers table. Fetch the company name in the company column of the customers table and the total amount that each has been invoiced by joining these tables.”
references: group-by aggregate joins
Q. Get the first_names and birth_dates of each of the employees in the format: January 01, 1976
references: dates
Q. Get the first_names and birth_dates of each of the employees in the format: Jan 1st, 1976
references: dates
Q. Get the first_names and birth_dates of each of the employees in the format: 09/23/1987
references: dates
Q. Get the year of the invoice_date in the format Y2012
and total number of invoices per year.
references: dates
Q. Get the year and month of invoices and the total amount that was invoiced for that year and month.
If you’ve completed all of these CONGRATULATIONS! You’re proficient and fluent enough in SQL now to complete a significant portion of analytic and transactional queries.
Written by:
Dave Fowler
Reviewed by:
Matt David