CodeBlanks Logo Icon CodeBlanks

Stock movements

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

query.sql
-- low stock
SELECT name, qty
FROM inventory
WHERE

Sample solution

query.sql
SELECT name, qty
FROM inventory
WHERE qty < 10

Expected 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

Question
SELECT name, qty FROM inventory
WHERE ____;
Answer
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

All lessons in Beginner