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

# WHERE

> Filter rows before they are grouped or aggregated

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

```sql theme={null}
FROM sales
  SHOW total_revenue, units_sold
  WHERE vendor = 'Nike' AND units_sold > 0
```

## Operators

| Operator                  | Meaning                                                 |
| ------------------------- | ------------------------------------------------------- |
| `=`                       | Equal to                                                |
| `!=`                      | Not equal to                                            |
| `<` `>` `<=` `>=`         | Less than, greater than, and the "or equal to" forms    |
| `IN (...)`                | Matches any value in a list                             |
| `NOT IN (...)`            | Matches none of the values in a list                    |
| `IS NULL` / `IS NOT NULL` | Tests for a missing value                               |
| `LIKE`                    | Matches text against a pattern, where `%` is a wildcard |
| `CONTAINS`                | Matches text that contains a substring                  |

Text values go in single quotes. A list uses parentheses, for example `reason IN ('too small', 'damaged')`. You can also compare one field to another, such as `available < reorder_point`.

```sql theme={null}
FROM returns
  SHOW units_returned, return_rate
  WHERE reason IN ('too small', 'damaged') OR reason IS NULL
```

## Named filters

Some datasets offer named filters that stand in for a common condition. On the `inventory` dataset, for example, `low_stock` selects items running low on cover, and `needs_reorder` selects items the reorder engine recommends buying now. Write the name on its own, and combine it with other conditions using `AND`.

```sql theme={null}
FROM inventory
  SHOW current_quantity, days_of_supply
  WHERE low_stock AND vendor = 'Nike'
```

`AND` binds tighter than `OR`. Use parentheses to group conditions when you mix the two. To filter on totals after grouping instead, use [HAVING](/stockfulql/syntax/having).
