Stock movements
- SQL course
- Beginner
- Lesson 109/115
- 5 min
Write INSERT queries to add new stock.
Querying stock
To query the inventory you use SELECT. You can filter by location or a minimum quantity.
SELECT name, qty
FROM inventory
WHERE qty < 10;This query lists items with fewer than 10 in stock.
name, qty is selected from inventory. WHERE keeps only the rows where qty < 10 holds.
Querying stock — details
A low-stock alert uses a qty < threshold query. It tells you when to reorder.
Practice Querying stock
Select name and qty from inventory where qty is less than 10.
Starter code
-- low stock
SELECT name, qty
FROM inventory
WHERESample solution
SELECT name, qty
FROM inventory
WHERE qty < 10Expected output
name qty Vidalı 5 Somun 3
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which condition is used for low stock?
- qty <> 10
- qty = 10
- qty > 10
- qty < 10 Correct answer
Explanation: qty < 10 finds low stock.
2 Filter stock
SELECT name, qty FROM inventory
WHERE ____;
SELECT name, qty FROM inventory
WHERE qty < 10;
Explanation: qty < 10 is the right answer.
3 Stock movements: match the terms
| Term | Meaning |
|---|---|
SELECT |
read |
WHERE |
filter |
qty |
quantity |
name |
name |