4.8/5
Home

Integrations

Plug Count neatly into your existing data infrastructure

For data teams

Collaborative, AI-driven data exploration and modelling

For product & growth

Faster access to the answers which matter

For leaders

Turning data into an engine of improvement

Pricing

Latest post

Meet the new Count Agent

Meet the new Count Agent

Docs

Guides, references, and API docs

Blog

Opinions, analysis, and the occasional uncomfortable truth about data.

Webinars

Join our experts for deep dives into data analytics and business intelligence

Gallery

Browse ready-to-use canvas templates and try them instantly

Sign in

Where to begin?

Start for free

Spin up a canvas and explore your data — a couple of clicks, no card.

Book a demo

See it live. Bring your questions — we’ll bring the answers.

Still not sure?

Send us a note — we’ll point you the right way.

Data to decisions, faster.

Compare

  • Count vs BI
  • Count vs Notebooks
  • Count vs Chatbots
  • Count vs Hex
  • Count vs Looker
  • Count vs Tableau
  • Count vs Thoughtspot

Learn

  • Blog
  • Webinars
  • SQL tutorials

Legal & security

  • Privacy Policy
  • Terms of Use
  • Cookies Policy
  • Trust Center
  • Security

Social

  • LinkedIn →
  • YouTube →
  • X →

Start with the hard question.

Ask Count anything — we’ll take you straight into a canvas.

Opens sign-up with your prompt ready for Count.

© 2026 Count Technologies Ltd. All rights reserved.

Careers →Book a Demo →
count

SQL Resources

Count is the best SQL IDE, wrapped up in the best data analysis tool, all inside the best BI platform.

COUNT
Dates
FROM
JOIN
Strings
WHERE
Simple WHERE expressionsCompound WHERE expressionsWHERE expressions on dates
SQL Resources/SQL/WHERE

WHERE

The WHERE clause is one of the fundamental building blocks of a SQL SELECT statement. In this article we'll explain how it works.

The WHERE clause is one of the fundamental building blocks of a SQL SELECT statement. In this article we'll explain how it works.

The WHERE clause is formed of the reserved 'where' keyword followed by what is known as a predicate expression - simply an expression which returns true or false.

If, for a given row, the predicate returns true, that row will be included in the output of the query.

If the predicate returns false, that row will be excluded.

Let's look at some examples.

-- Generic SQL SELECT statement
select
  -- (some columns)
from
  -- (some tables)
where
  -- (A 'predicate' expression to be used as a filter)
group by
  -- (some columns)
ℹ️

In this article the code snippets are written in the Google BigQuery Standard SQL syntax.

Simple WHERE expressions

In these examples, the predicate expression in the WHERE clause is a simple boolean expression - an expression that returns true or false.

with my_table as (select * from unnest([1,2,3,4,5]) as numbers)
select numbers from my_table
where
  numbers > 2 -- This is the predicate expression

Inequality

numbers
3
4
5

IS NOT NULL

numbers
2
3
4
numbers
null
null
numbers
2
3
4

Compound WHERE expressions

In the following examples, the WHERE clause contains more complex predicate expressions, using the building blocks of the AND and OR logical operators.

with my_table as (select * from unnest([1,2,3,4,5]) as numbers)
select numbers from my_table
where
  numbers = 2
strings
ab
aa
bb

SELECT statements

numbers
3
4
5

WHERE expressions on dates

When using dates and times, all of the same rules apply. The predicate expression in the WHERE clause must still return true or false, but you are free to use functions and compound logical expressions.

dates
2020-01-01

Inequality

dates
2020-01-06
2020-01-07
2020-01-08
2020-01-09
2020-01-10
dates
2020-01-02
2020-01-03
2020-01-04
dates
2020-01-05
with my_table as (select * from unnest([null,2,3,4,null]) as numbers)
select numbers from my_table
where
  numbers is not null
with my_table as (select * from unnest([null,2,3,4,null]) as numbers)
select numbers from my_table
where
  numbers is null
with my_table as (select * from unnest([1,2,3,4,5]) as numbers)
select numbers from my_table
where
  numbers in (1,2)
with my_table as (select * from unnest([1,2,3,4,5]) as numbers)
select numbers from my_table
where
  numbers between 2 and 4 -- Note - these limits are inclusive
with my_table as (select * from unnest([1,2,3,4,5]) as numbers)
select numbers from my_table
where
  -- Use brackets to control precedence
  numbers > 2 and (numbers < 3 or numbers > 4)
with my_table as (select * from unnest(['a', 'b', 'ab', 'aa', 'bb', 'cc']) as strings)
select strings from my_table
where
  -- Predicate expressions can contain functions
  (strings like 'a%' or strings like 'b%') and length(strings) = 2
with my_table as (select * from unnest([1,2,3,4,5]) as numbers)
select numbers from my_table
where
  -- Predicate expressions can contain other select statements
  numbers > (select 1+1)
with my_table as (
  select * from unnest(generate_date_array('2020-01-01', '2020-01-10')) as dates
)
select dates from my_table
where
  dates = '2020-01-01'
with my_table as (
  select * from unnest(generate_date_array('2020-01-01', '2020-01-10')) as dates
)
select dates from my_table
where
  dates > '2020-01-05'
with my_table as (
  select * from unnest(generate_date_array('2020-01-01', '2020-01-10')) as dates
)
select dates from my_table
where
  -- Note - between is inclusive
  dates between '2020-01-02' and '2020-01-04'
with my_table as (
  select * from unnest(generate_date_array('2020-01-01', '2020-01-10')) as dates
)
select dates from my_table
where
  extract(day from dates) = 5 and extract(month from dates) = 1

Got a CSV?
See it differently in <2 mins

Get started for FREEWatch our CEO do it