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

# WHERE

> Keep only the rows that match, before they're grouped and totalled.

`WHERE` keeps only the rows that match your conditions, before any grouping or totalling. A condition compares a field with a value. Chain conditions with `AND` and `OR`.

```sql theme={null}
FROM sales
  SHOW net_sales, orders
  WHERE product_vendor = 'Acme' AND sales_channel = 'Online Store'
```

`WHERE` filters on dimensions, not metrics. To keep only the groups whose totals match, use [HAVING](https://docs.queryful.app/queryfulql/syntax/having.md).

## Operators

| Operator | Matches |
| - | - |
| `=` `!=` | Equal, not equal |
| `<` `>` `<=` `>=` | Less than, greater than, and the "or equal" forms |
| `BETWEEN a AND b` | A number or date from a to b, inclusive |
| `IN (...)` `NOT IN (...)` | Any of a list of values, or none of them |
| `CONTAINS` `NOT CONTAINS` | Text that contains a piece of text, or doesn't |
| `STARTS WITH` `ENDS WITH` | Text that starts or ends with a piece of text, and their `NOT` forms |
| `LIKE` | Text matching a pattern, where `%` stands for anything |
| `IS NULL` `IS NOT NULL` | A missing value, or any value |

Text values go in single quotes, lists in brackets:

```sql theme={null}
FROM sales
  SHOW net_sales
  WHERE customer_country IN ('United Kingdom', 'Ireland') AND product_title CONTAINS 'gift'
```

Which operators a field takes depends on its type: text, numbers, dates or yes/no. The editor only suggests the ones that fit.

## Dates

Date fields take dates written as `2026-01-31`, or the relative dates from [SINCE and UNTIL](https://docs.queryful.app/queryfulql/syntax/since-until-during.md), like `-30d` and `today`.

```sql theme={null}
FROM customers
  SHOW total_amount_spent, total_number_of_orders
  WHERE customer_last_order_date BETWEEN -90d AND today
  GROUP BY customer_country
```

## Grouping conditions

`AND` is worked out before `OR`. Use brackets when you mix them:

```sql theme={null}
FROM sales
  SHOW net_sales
  WHERE (product_vendor = 'Acme' OR product_vendor = 'Globex') AND discount_code IS NOT NULL
```

You can also compare one field with another of the same type, such as `product_variant_price < product_variant_compare_at_price`.


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