SQL · Pattern 1 — Basic Data Retrieval
LIMIT / TOP / FETCH FIRST
These cap how many rows come back, which matters once a table has thousands (or millions) of rows and you only need a preview.
Source data — Pattern 1: Basic Data Retrieval
All queries run against the shared employees table (see schema.sql).

What it does
These cap how many rows come back, which matters once a table has thousands (or millions) of rows and you only need a preview. Every major database does this slightly differently — one of the few places dialect really matters for something this basic.
Problem
Display the first 5 employees.
-- MySQL / PostgreSQL / SQLite
SELECT *
FROM employees
LIMIT 5;
-- SQL Server
SELECT TOP 5 *
FROM employees;
-- Oracle
SELECT *
FROM employees
FETCH FIRST 5 ROWS ONLY;
Result
