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

# query - Views

> Defines a view from a workbook query.

Defines a view from a workbook query.

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

## Syntax

```yaml theme={null}
query:
  fields:
    <view_name>.<field_name>
    <view_name>.<field_name>: <optional_alias>
  base_view: <view_name>
  filters: [ ... ]
```

## Properties

<ParamField path="query" type="object">
  An object containing query sub-parameters.

  <Expandable title="query properties" defaultOpen>
    <ParamField path="fields" type="array">
      Fields to include in the query, specified as `view_name.field_name`. To alias fields, specify as `view_name.field_name: alias`.
    </ParamField>

    <ParamField path="base_view" type="string">
      The view to use as the base for the query.
    </ParamField>

    <ParamField path="filters" type="object">
      Filters to apply to the query, specified using [filter syntax](/modeling/filters).
    </ParamField>
  </Expandable>
</ParamField>

## Examples

In this example, `query.fields` contains aliased fields - that is, the string **after** the colon defines the alias. For example, `created_at`.

The `dimensions.sales` field is an example of a field that was **not** aliased.

```yaml title="Example with aliased fields" theme={null}
query:
  fields:
    order_items.created_at[date]: created_at
    order_items.user_id: user_id
    order_items.total_sales
  filters:
    orders.amount_returns:
      not: 0
  base_view: order_items

dimensions:
  created_at:
    timeframes: [date]
    sql: created_at
  user_id:
    sql: user_id
  sales:
    sql: order_items__total_sales
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.