50 SQL Practice Queries and Answers

Musili Adebayo
3 min readJan 11, 2021
Photo by olia danilevich from Pexels

Are you trying to become proficient at extracting business queries? Then this article is for you.

As an aspiring data-driven professional, becoming proficient at extracting SQL queries from databases is not a herculean task as you might have perceived it to be. All that is required is consistency and constant practice. At the end of attempting these 50 business queries and answers, you will become confident in your skills at writing business queries because these practice queries will cover most SQL syntax like create, insert, update, delete, wildcard expressions, etc.

There are many popular databases like Oracle, MySQL, SQL Server, Maria DB, PostgreSQL, etc. However, we will be focusing on the MySQL database for extracting these business queries using the popular Northwind Database from Microsoft Access.

Why MySQL?

MySQL is a free and open-source relational database system and its popular with many database web-driven applications including PHP, Drupa, WordPress, and popular websites like Facebook, Twitter, YouTube, Instagram, Google, etc.

However, before we get started, let’s install MySQL by visiting this link.

Also, visit my Git page: here or my onedrive to download the Northwind Database folder and the 50 practice queries below.

50 Northwind Practice Queries.pdf

First, we create a database called “northwind” or any other name you might prefer.

CREATE DATABASE IF NOT EXISTS northwind;

Then we use northwind as our schema.

USE northwind;
  1. Create a report that shows the CategoryName and Description from the categories table sorted by CategoryName.
SELECT CategoryName, DescriptionFROM northwind.categoriesORDER BY CategoryName;

The query should return this result:

2. Create a report that shows the ContactName, CompanyName, ContactTitle and Phone number from the customers table sorted by Phone.

SELECT ContactName, CompanyName, ContactTitle, PhoneFrom northwind.customersORDER BY Phone;

The query should return 91 rows:

3. Create a report that shows the capitalized FirstName and capitalized LastName renamed as FirstName and Lastname respectively and HireDate from the employees table sorted from the newest to the oldest employee.

SELECT UPPER(FirstName) AS FirstName, UPPER( LastName) AS LastName, HireDateFROM northwind.employeesORDER BY HireDate;

The query should return this result:

4. Create a report that shows the top 10 OrderID, OrderDate, ShippedDate, CustomerID, Freight from the orders table sorted by Freight in descending order.

SELECT OrderID, OrderDate, ShippedDate, CustomerID, FreightFROM northwind.ordersORDER BY Freight DescLIMIT 10;

The query should return this result:

5. Create a report that shows all the CustomerID in lowercase letter and renamed as ID from the customers table.

SELECT lower(CustomerID) AS IDFROM northwind.customers;

The query should return this result:

I hope these 5 queries give you a glimpse of what the remaining 45 queries and answers will look like. Kindly, download the Northwind Database folder on my GIT page or through Onedrive.

Check out my Analytics Portfolio here

Thank you for reading.

Remember to subscribe and follow me for more insightful articles and you can reach me via my socials below if you want to discuss further.
LinkedIn: Musili Adebayo
Twitter: Musili_Adebayo

P.S. Enjoy this article? Support my work directly.

--

--

Musili Adebayo

I am quite the storyteller, once a good idea pops up in my head. I enjoy talking about modern data stack and how to leverage them.