Stop 03 · SQL for Data AnalysisTopics · 1/10

SQL Basics (SELECT, WHERE, ORDER BY)

Part of the Data Analyst Roadmap

In short

Company data lives in databases with millions of rows. SQL is how you politely ask for just the rows you need, and it reads almost like plain English.

The core statement pattern of SQL — SELECT which columns, FROM which table, WHERE to filter rows, ORDER BY to sort results — the foundation every other SQL skill builds on.

The jaadu pulls chosen books from a tall library shelf onto a cart.

Think of it like this

Asking the librarian

You don't carry the whole library home. You tell the librarian: "Only the titles and authors (SELECT), from the fiction shelf (FROM), published after 2015 (WHERE), newest first (ORDER BY)." SQL is that request slip, written for a database.

Watch it happen

How the database reads your query

FROM
WHERE
SELECT
ORDER BY
LIMIT

1/5First it opens the orders table: all 50,000 rows.

The big ideas

What you need to know

SELECT picks columns

Name the columns you need. SELECT * grabs everything, fine for a peek, wasteful in real queries.

WHERE filters rows

Use =, >, <, IN, BETWEEN, LIKE and combine with AND / OR. Text goes in single quotes.

ORDER BY sorts

ASC is the default. Add DESC for biggest or newest first.

NULL is special

Missing values are NULL. Use IS NULL or IS NOT NULL. = NULL never matches anything.

See it in code

Walk through the code

sql
1SELECT order_id, customer_id, amount, order_date2FROM orders3WHERE city = 'Pune'4  AND amount > 5005  AND order_date >= '2026-01-01'6ORDER BY amount DESC7LIMIT 10;

1/3Which columns, from which table.

The ten biggest Pune orders above ₹500 this year. LIMIT works in PostgreSQL, MySQL and SQLite. SQL Server uses TOP instead.

Save yourself the pain

Common mistakes

Oops

Writing WHERE discount = NULL to find missing discounts.

Do this instead

Use WHERE discount IS NULL. Comparing anything to NULL with = gives unknown, so no rows match.

Oops

Mixing AND and OR without brackets.

Do this instead

WHERE city = 'Pune' AND (status = 'paid' OR status = 'shipped'). Brackets make the logic clear.

Your mission

Your first five queries

~25 min

Quick check

In which order does the database actually process these clauses?

Go deeper

  1. 1Write 10 basic SELECT queries against a free sample database.
  2. 2Practice combining multiple WHERE conditions with AND/OR.
  3. 3Learn the exact clause order SQL requires (SELECT, FROM, WHERE, ORDER BY).

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge