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

# always_having_sql

> Applies a filter to aggregated results in a query using SQL.

This parameter is functionally identical to [`always_having_filters`](/modeling/topics/parameters/always-having-filters), but uses SQL instead of [filter syntax](/modeling/filters).

When defined, a filter will be inserted into the `HAVING` clause of the generated SQL block of all queries in the topic. Users with the **Querier** role can't change this filter and it will be visible only in the underlying SQL of any queries. This filter is additive to any measure filters specified in the workbook.

Conditions should be written using `${}` syntax to reference fields defined in Omni.

<Tip>
  You can generate a syntactically correct condition using the workbook:

  1. In a workbook, add the filter using the UI.
  2. Click the **SQL** button near the top-right corner of the page.
  3. Copy the content of the `HAVING` clause.
  4. Paste the contents into the `always_having_sql` parameter.
</Tip>

## Syntax

```yaml theme={null}
always_having_sql: "<sql_condition>"
```

## Properties

<ParamField path="always_having_sql" type="string">
  A SQL condition that is applied to the `HAVING` clause of all queries in the topic. Use `${}` syntax to reference fields defined in Omni (e.g., `${view_name.measure_name}`).
</ParamField>

## Examples

```yaml theme={null}
always_having_sql: ${users.count} > 5
```
