Mid Level SQL Practice Grounds

Learn SQL

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 all the tracks that are over 300000 milliseconds long.
References: where

Q. Fetch the id for the artist ‘Miles Davis’.
References: where

Q. Get all the tracks with gerne_id of 20 from longest to shortest.
References: where order-by

Q. Get the artists who’s ids are between 55 and 98.
References: operators

Q. Get all the tracks except those with genre_ids of 15 or 18.
References: operators

Q. Get all the tracks that were composed by just Miles Davis
References: operators

Q. Get all the tracks that Miles Davis had a part in composing.
References: operators

Q. Fetch the the names of the tracks with the word ‘wild’ in it, regardless of case
References: operators

Q. How many tracks did Little Richard helped compose?
References: operators aggregate

Q. How many tracks with genre_id of 1 have composers listed?
References: aggregate

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. Get a list of genre_ids and the number of tracks in each.
References: group-by

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
References: order-by group-by

Q. Take the above query with the same ordering but group by album_id and then group_id and change the order of the results to reflect that switch.
References: order-by group-by

Q. Get the first 5 tracks JOINed with their albums info.
References: joins limit

Q. Get the first 5 albums JOINed with thier artists info.
References: joins limit

Q. Return each customer_id and the total of all of their invoices.
References: group-by aggregate

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 month of invoices and the total amount that was invoiced for that month.
References: dates aggregate

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.


If you're finding this SQL Tutorial helpful, you may also enjoy our product Chartio. Chartio is on a mission to enable anyone in a company with the power of a data analyst. To do so we've built a very user friendly interface for people to explore and visualize data with either SQL, or our drag and drop Visual SQL. You can connect to all of your different data sources, and quickly create visuals and dashboards to share with your team. Give us a spin, there's a 2 week free trial.