Project: the categories that matter most
SQL · Unit 6: Grouping
- Full plan
- SQL
- Project
- 3 exercises
The owner is going to insure the warehouse, and the insurer only covers the sections that hold 1000 or more in merchandise. Which ones are they, and how much is each worth?
You opened this unit with the value of each section, last unit's four queries in one. What's left is to keep the sections big enough to matter and sort them.
Exercises in this lesson
You do them in the app, which checks them on the spot and explains why.
1. Put the lines in order
First, the full list: each section with the value of what it holds, from the most valuable to the least. Put the query in order. One line doesn't belong.
2. Write the code
The report for the insurer. Write a query with two columns, in this order: the category and the value of what it holds, which is the sum of
price * stock. Only the sections that hold 1000 or more, from the most valuable to the least.3. Write the code
The insurer adds one more condition. It doesn't cover items that cost less than 20 apiece, so those stay out of the total. Write the query with three columns, in this order: the category, how many of its products are covered, and the value they add up to. As before, only the sections that reach 1000, from the most valuable to the least.
It opens in your browser. This lesson is part of the full plan; the first unit of each course is free.