

# `WHERE` clause

The `WHERE` clause keeps the rows for which `condition` is true. Rows for which the condition is false or `NULL` are left out. The condition can use the columns of the `FROM` clause, the aliases of the select list, and subqueries, but not aggregate or window functions. To filter on aggregates, use `HAVING`, and to filter on window functions, use `QUALIFY`.

## Syntax
<a name="athena-duckdb-statement-select-where-syntax"></a>

```sql
WHERE {{condition}}
```

## Examples
<a name="athena-duckdb-statement-select-where-examples"></a>

For a description of the sample tables that the examples on this page use, see [SELECT statement in DuckDB](duckdb-statement-select.md).

The following SQL query returns the orders in the `east` region with an amount over 40. The order with a `NULL` amount is left out, because comparing `NULL` with 40 does not return true.

```sql
SELECT order_id, customer, amount
FROM sales_db.sales_parquet
WHERE region = 'east' AND amount > 40
ORDER BY order_id
```

The query returns the following results.


| order\_id | customer | amount | 
| --- | --- | --- | 
| `1` | `alice` | `120.50` | 
| `3` | `carol` | `42.25` | 

The following SQL query filters on `doubled`, an alias defined in the select list.

```sql
SELECT order_id, amount * 2 AS doubled
FROM sales_db.sales_parquet
WHERE doubled > 200
ORDER BY order_id
```

The query returns the following results.


| order\_id | doubled | 
| --- | --- | 
| `1` | `241.00` | 
| `4` | `620.00` | 

The following SQL query returns the order whose amount is `NULL`.

```sql
SELECT order_id, customer
FROM sales_db.sales_parquet
WHERE amount IS NULL
```

The query returns the following result.


| order\_id | customer | 
| --- | --- | 
| `6` | `frank` | 