w3resource logo


MySQL exercises

MySQL Northwind database, Products table - Exercises, Practice, Solution

Secondary Nav

Queries on Products table [10 exercises with solution]

Structure of Products table :

northwind database products table

Sample records of Products Table :

+-----------+---------------------------------+------------+------------+---------------------+-----------+--------------+--------------+--------------+--------------+
| ProductID | ProductName                     | SupplierID | CategoryID | QuantityPerUnit     | UnitPrice | UnitsInStock | UnitsOnOrder | ReorderLevel | Discontinued |
+-----------+---------------------------------+------------+------------+---------------------+-----------+--------------+--------------+--------------+--------------+
|         1 | Chai                            |          1 |          1 | 10 boxes x 20 bags  |   18.0000 |           39 |            0 |           10 |              |
|         2 | Chang                           |          1 |          1 | 24 - 12 oz bottles  |   19.0000 |           17 |           40 |           25 |              |
|         3 | Aniseed Syrup                   |          1 |          2 | 12 - 550 ml bottles |   10.0000 |           13 |           70 |           25 |              |
|         4 | Chef Anton's Cajun Seasoning    |          2 |          2 | 48 - 6 oz jars      |   22.0000 |           53 |            0 |            0 |              |
|         5 | Chef Anton's Gumbo Mix          |          2 |          2 | 36 boxes            |   21.3500 |            0 |            0 |            0 | ☺            |
|         6 | Grandma's Boysenberry Spread    |          3 |          2 | 12 - 8 oz jars      |   25.0000 |          120 |            0 |           25 |              |
|         7 | Uncle Bob's Organic Dried Pears |          3 |          7 | 12 - 1 lb pkgs.     |   30.0000 |           15 |            0 |           10 |              |
|         8 | Northwoods Cranberry Sauce      |          3 |          2 | 12 - 12 oz jars     |   40.0000 |            6 |            0 |            0 |              |
|         9 | Mishi Kobe Niku                 |          4 |          6 | 18 - 500 g pkgs.    |   97.0000 |           29 |            0 |            0 | ☺            |
|        10 | Ikura                           |          4 |          8 | 12 - 200 ml jars    |   31.0000 |           31 |            0 |            0 |              |
|        11 | Queso Cabrales                  |          5 |          4 | 1 kg pkg.           |   21.0000 |           22 |           30 |           30 |              |
|        12 | Queso Manchego La Pastora       |          5 |          4 | 10 - 500 g pkgs.    |   38.0000 |           86 |            0 |            0 |              |
|        13 | Konbu                           |          6 |          8 | 2 kg box            |    6.0000 |           24 |            0 |            5 |              |
|        14 | Tofu                            |          6 |          7 | 40 - 100 g pkgs.    |   23.2500 |           35 |            0 |            0 |              |
|        15 | Genen Shouyu                    |          6 |          2 | 24 - 250 ml bottles |   15.5000 |           39 |            0 |            5 |              |
....
+-----------+---------------------------------+------------+------------+---------------------+-----------+--------------+--------------+--------------+--------------+

1. Write a query to get Product name and quantity/unit. Go to the editor

Click me to see the solution

2. Write a query to get current Product list (Product ID and name). Go to the editor

Click me to see the solution

3. Write a query to get discontinued Product list (Product ID and name). Go to the editor

Click me to see the solution

4. Write a query to get most expense and least expensive Product list (name and unit price). Go to the editor

Click me to see the solution

5. Write a query to get Product list (id, name, unit price) where current products cost less than $20. Go to the editor

Click me to see the solution

6. Write a query to get Product list (id, name, unit price) where products cost between $15 and $25. Go to the editor

Click me to see the solution

7. Write a query to get Product list (name, unit price) of above average price. Go to the editor

Click me to see the solution

8. Write a query to get Product list (name, unit price) of ten most expensive products. Go to the editor

Click me to see the solution

9. Write a query to count current and discontinued products. Go to the editor

Click me to see the solution

10. Write a query to get Product list (name, units on order , units in stock) of stock is less than the quantity on order. Go to the editor

Click me to see the solution

 

... More

Structure of 'northwind' database :

mysql northwind database

MySQL Online Editor




Join our Question Answer community to learn and share your programming knowledge.