← all levels

Beginner

the stuff every single query is built on.

  1. 01SELECT & basic queriesOk so this is where everything starts. Every query you'll ever write has a SELECT in it somewhere, it's basically you telling the database "hey, give me these columns from this table".
  2. 02WHERE & filteringSELECT gets you columns, WHERE decides which rows make it. Without WHERE you get the whole table, with it you get only the rows that pass your condition.
  3. 03logical operators (AND, OR, NOT)One condition is rarely enough. Like "orders from Delhi" is fine but "delivered orders from Delhi above 1000" is what people actually ask for. That's where AND, OR and NOT come in.
  4. 04NULL handlingNULL means "we don't know". Not zero, not empty string, not false. Just unknown. And once you get that, all the weird NULL behaviour starts making sense.
  5. 05sorting with ORDER BYHere's something people don't expect, without ORDER BY the database gives you rows in whatever order it feels like. It might look sorted today and come back different tomorrow. If order matters, say it.
  6. 06LIMIT & OFFSETLIMIT says "only give me this many rows". OFFSET says "skip this many first". That's literally it, but there are a couple of gotchas.
  7. 07aggregation basics (COUNT, SUM, AVG, MIN, MAX)Up till now every query gave back rows from the table. Aggregates squash a bunch of rows into one number. "How many orders?", "total revenue?", "average salary?", all of these are aggregates.
  8. 08DISTINCTDISTINCT removes duplicate rows from your result. Simple idea, but people misuse it a lot so let's go through it properly.
  9. 09data typesEvery column has a type, and the type decides what you can store and what you can do with it. You can't do math on text, you can't do date stuff on a number. Picking the right type early saves so much pain later.
  10. 10CASE WHEN (if else in sql)CASE is how you write if/else logic inside a query. You'll use it for labels, buckets, custom sorting, and later for really useful stuff like conditional counting.