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

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.omni.co/feedback

```json
{
  "path": "/modeling/measures/parameters/sql",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# sql

> The core declaration of the field definition.

## Syntax

```yaml theme={null}
<measure_name>:
  sql: ${<view_name>.<field_name>}
```

## Properties

<ParamField path="measure_name" type="object[]">
  The name of the measure.

  <Expandable title="measure_name properties" defaultOpen="true">
    <ParamField path="sql" type="string">
      A SQL expression that defines the measure. Can include field references using `${}` syntax, raw SQL functions, or arithmetic operations.

      Field type is implicit in Omni, and defined based upon the underlying field's database type. To change the type, `CAST` the field (for example, `sql: ${zip_code}::string`).

      <Tip>
        When referencing other fields, use Omni field references (`${view.name}`) instead of the raw database name. For example, `${orders.id}`
      </Tip>
    </ParamField>
  </Expandable>
</ParamField>

## Examples

```yaml title="Sum of a field" theme={null}
total_revenue:
  sql: ${orders.sales_price}
  aggregate_type: sum
```

```yaml title="Measure with division" theme={null}
revenue_per_order:
  sql: ${orders.total_revenue} / ${orders.count}
```

```yaml title="Custom SQL function" theme={null}
average_revenue:
  sql: AVG(${orders.sales_price})
```
