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

# sql

> Defines a view from a SQL query.

<Tip>
  For an easier building experience, build your [SQL view using the workbook](/analyze-explore/sql) and then promote it to the shared model.
</Tip>

## Syntax

```yaml theme={null}
sql: |
  SELECT <statement>
```

## Properties

<ParamField path="sql" type="string">
  A raw SQL query that defines the view.
</ParamField>

## Examples

```yaml title="SQL view with primary key" theme={null}
sql: |
  SELECT *
  FROM users
  LIMIT 10

dimensions:
  id:
    sql: id
    primary_key: true
  first_name:
    sql: first_name
```
