Skip to main content

Basic SELECT

Select one or more expressions from a table:

Column Aliases

Use AS to name an output column, or omit AS and place the alias directly after the expression:
Aliases defined in the SELECT list can be referenced in ORDER BY.

Delimited Identifiers

Use ANSI double quotes when a table name, column name, or alias includes punctuation, spaces, reserved words, leading digits, or exact-case DynamoDB names:
Double quotes delimit identifiers only. Single quotes still create string literals:

SELECT *

Expand all columns from all referenced tables:
Expand all columns from a specific table when multiple tables are in scope:

SELECT DISTINCT

Deduplicate rows in the result set:

ORDER BY

Sort results by one or more columns. Each sort key can be ASC (default) or DESC. Multiple sort keys are separated by commas:
Aliases from the SELECT list are usable in ORDER BY:
NULL ordering: NULL values sort before non-null values when ascending, and after non-null values when descending. NULLS FIRST and NULLS LAST are not supported.

LIMIT

Cap the number of rows returned:
ANSI FETCH FIRST n ROWS ONLY is equivalent:
OFFSET skips a fixed number of rows before returning results:
For paginating through a full result set, prefer the maxRows / resumeIdx API options over SQL OFFSET. See Pagination.