Skip to content

Lab · Backend Development

Lab: SQL for a kirana shop

Labbeginner· about 1.5 hours· 4 steps

The brief

Sharma General Store keeps its products in a database table. Answer the owner's questions with SQL: cheap staples in stock, the most expensive items, this week's changes to the table, and the headline numbers of the stock.

Why it matters

Every backend route ends in a query like these: a product list with a filter, a "top items" widget, an update when stock arrives, and a dashboard number. Billing software in lakhs of Indian shops runs on exactly this SQL.

Skills you practise

  • SELECT and WHERE with AND
  • ORDER BY and LIMIT
  • INSERT, UPDATE and DELETE
  • COUNT, SUM, AVG and ROUND

What you will have at the end

Four SQL files that answer a shop owner's everyday questions and make the week's changes safely.

How it is marked (rubric, 100 points)
Correct resultsEvery check passes.50
Safe changesEvery UPDATE and DELETE has a WHERE on the id; INSERT lists its columns.20
Readable SQLKeywords in capitals, one clause per line, clear column aliases.20
Can explainYou can say what would go wrong with an UPDATE that has no WHERE.10

0/4 steps done

Step 1 of 4

Cheap staples in stock

01-cheap-staples.sql returns the name and price of every Staples product under ₹100 with stock above 0, cheapest first.

SELECT picks the columns, FROM the table, and WHERE keeps only the rows you want. Join conditions with AND: all of them must be true. Text values go in single quotes, and they must match exactly (Staples, not staples). ORDER BY price sorts from low to high.

Run shows what your code prints. Check runs the step's tests. Ctrl+Enter checks too.