---
schema_version: "1"
id: c00ddf3d25b7a653a8ad1f6a8fb9ed15d48672306d8cbe5a768d379fdb6fa7cd
title: WHERE Clause
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_sql/guides/bi-sql-where.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-sql/guide/bi-sql-where.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 5d3acffaa72afcaccf4a49fda22289e52b4e05cffe759d0971a11f7818caf113
products:
  - SQL for Analytics Developer Guide
  - analytics
---

# WHERE Clause

By default, a SQL query retrieves every row in your dataset. Use the optional `WHERE` clause to restrict your query results to a conditional expression.

The conditional expression in the `WHERE` clause takes the following syntax.

```nolang
fieldExpression [logicalOperator fieldExpression2][...]
```

```nolang
SELECT COUNT(*) as Count
FROM "Superstore"
WHERE City = 'San Francisco';
```

| Count |
| ----- |
| 510   |

You can add multiple field expressions to conditional expressions with logical operators.

```nolang
SELECT COUNT(*) as Count FROM "Superstore"
WHERE City = 'Los Angeles' OR City = 'San Francisco';
```

| Count |
| ----- |
| 1,257 |

The `WHERE` clause supports these operators.

| Type                 | Operator Name          | Supported Types          |
| -------------------- | ---------------------- | ------------------------ |
| Comparison Operators | !=, =                  | Numeric, String, Boolean |
|                      | \<, \<=, >, >=         | Numeric, String          |
|                      | `IN`, `NOT IN`         | Numeric, String          |
| Null Operators       | `IS NULL, IS NOT NULL` | Numeric                  |
| Logical Operators    | `AND, OR, NOT`         | Boolean                  |

The left operand of a comparison operator must be a valid field. The right operand cannot be a field. Arithmetic operators (e.g. +, -, /, \*, %) between supported types can be used on the right hand side.

`WHERE` is limited to comparisons within a single column.

In a non-nested query (a non-subquery), you can’t pass fields to a math or string function in a `WHERE` clause. You can pass a constant. To pass fields to a math or string function in a subquery, include it in the outer query’s `WHERE` clause. If you use it in the innermost query, SQL throws an error.
