compare syntax one concept · three SQL dialects
Compare Syntax
See how the same SQL concept is written in SQLite, PostgreSQL and SQL Server.
Limit output
Return a small, predictable set of rows: here, the five most recent invoices.
what differs
SQLite and PostgreSQL put LIMIT after ORDER BY. SQL Server puts TOP after SELECT. Ordering by a unique tie-breaker (order_id) makes the chosen rows predictable.
at a glance
| dialect | how it is written |
|---|---|
| SQLite | … ORDER BY … LIMIT 5 |
| PostgreSQL | LIMIT 5 or FETCH FIRST 5 ROWS ONLY |
| SQL Server | SELECT TOP (5) … ORDER BY … |
in Runtime
The SQLite version runs for real in the editor under the examples. PostgreSQL and SQL Server are shown for reference; they do not run here.