> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamosql.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SELECT

> Column selection, aliases, DISTINCT, ORDER BY, and LIMIT.

## Basic SELECT

Select one or more expressions from a table:

```sql theme={null}
SELECT id, name, email FROM myschema.users
```

## Column Aliases

Use `AS` to name an output column, or omit `AS` and place the alias directly after the expression:

```sql theme={null}
SELECT id, total * 1.1 AS total_with_tax FROM myschema.orders
SELECT id, total * 1.1 total_with_tax FROM myschema.orders  -- bare alias
```

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:

```sql theme={null}
SELECT
  "order-id",
  "Safety.Warning",
  total AS "Total Amount"
FROM east."prod-orders"
ORDER BY "order-id"
```

Double quotes delimit identifiers only. Single quotes still create string literals:

```sql theme={null}
SELECT 'order-id' AS label, "order-id" FROM east."prod-orders"
```

## SELECT \*

Expand all columns from all referenced tables:

```sql theme={null}
SELECT * FROM myschema.products
```

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

```sql theme={null}
SELECT o.*, c.name FROM myschema.orders AS o
INNER JOIN myschema.customers AS c ON o.customer_id = c.id
```

## SELECT DISTINCT

Deduplicate rows in the result set:

```sql theme={null}
SELECT DISTINCT status FROM myschema.orders
```

## 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:

```sql theme={null}
SELECT id, name FROM myschema.products ORDER BY name
SELECT id, name FROM myschema.products ORDER BY name DESC
SELECT id, created_at, total FROM myschema.orders ORDER BY created_at ASC, total DESC
```

Aliases from the `SELECT` list are usable in `ORDER BY`:

```sql theme={null}
SELECT customer_id, SUM(total) AS lifetime_value
FROM myschema.orders
GROUP BY customer_id
ORDER BY lifetime_value DESC
```

**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:

```sql theme={null}
SELECT * FROM myschema.events LIMIT 100
```

ANSI `FETCH FIRST n ROWS ONLY` is equivalent:

```sql theme={null}
SELECT * FROM myschema.events FETCH FIRST 100 ROWS ONLY
```

`OFFSET` skips a fixed number of rows before returning results:

```sql theme={null}
SELECT * FROM myschema.products LIMIT 10 OFFSET 20
```

<Note>
  For paginating through a full result set, prefer the `maxRows` / `resumeIdx` API options over SQL `OFFSET`. See [Pagination](/guides/pagination).
</Note>
