Sams Teach Yourself SQL in 10 Minutes (Fifth Edition) includes challenges at the end of some lessons. Solutions to the challenges are presented here. Just keep in mind that there is rarely one solution to a SQL challenge, so if your solutions look different but produce the desired result, that’s ok.

Lesson 9

Write a SQL statement to determine the total number of items sold (using the quantity column in OrderItems).


SELECT SUM(quantity) AS items_ordered
FROM OrderItems;
Category: Lesson 9

Modify the statement you just created to determine the total number of products with an id (prod_id) BR01 sold.


SELECT SUM(quantity) AS items_ordered
FROM OrderItems
WHERE prod_id = 'BR01';

Category: Lesson 9

Write a SQL statement to determine the price (prod_price) of the most expensive item in the Products table which costs no more than 10, name the calculated field max_price.


SELECT MAX(prod_price) AS max_price
FROM Products
WHERE prod_price <= 10;
Category: Lesson 9

Load More