bhylu.com

Advertisements

SQL Keywords

Keywords mark the structure of a statement: which data to read, how to filter it, and whether to change it. Use this page as a map back to the worked lessons rather than trying to learn a list in isolation.

Understand the idea

A useful reading order for a simple report is FROM and JOIN to identify input, WHERE to keep rows, GROUP BY to form groups, HAVING to keep groups, SELECT to describe output, then ORDER BY and a row limit. This is a reasoning aid, not a promise of the database's physical execution steps. The keyword links below lead to complete explanations and examples.

Where to try it

Run this example in the SQL playground. The lesson link loads the shop tables and sample rows before this query. Select Run when you are ready. Every run starts fresh, so your changes do not affect the website or a previous run.

SQLite sample data · MySQL / MariaDB sample data · See the sample tables

A worked example

SQLite

SELECT status, SUM(total_cents) AS cents
FROM orders
WHERE total_cents > 0
GROUP BY status
HAVING SUM(total_cents) >= 900
ORDER BY cents DESC;

Read the result

Paid at 3650 and pending at 900 remain. The cancelled group's 250-cent total fails HAVING. Each clause has a separate role even though the engine may optimise the physical work.

Try one change

Read this statement from its input tables through to its final ordering. Explain why the amount condition on an individual row differs from the grouped-total condition.

Keyword map

Open a linked lesson for the concept and its database-specific spelling. Entries such as EXEC, ROWNUM, BACKUP DATABASE, ALTER COLUMN, and TRUNCATE TABLE are dialect-specific; their presence here does not mean SQLite accepts them.

Advertisements