SQL OR

A row survives if at least ONE condition is true — the opposite bar from AND.

What & Why

OR combines two or more conditions — a row survives if any of them is true, even if the rest are false.

See How It Works

BUSINESS QUESTION

Campaigns in email, or campaigns with spend greater than 55,000.

idnamechannelspendstart_dateend_datestatustarget_segment
1Spring Launchgoogle_ads55000.002024-01-152024-03-31activesmb
2Retention Webinaremail45000.002024-02-102024-04-15activeenterprise
3Finance Retargetinglinkedin50000.002024-03-122024-05-31activeenterprise
4Enterprise Searchgoogle_ads60000.002024-04-012024-06-30activeenterprise
Watch or check each rowRow 1 of 4
-- checking Spring Launch: google_ads = email OR 55000 > 55000?FALSE — dropped
namechannelspend
Spring Launchgoogle_ads55000
Retention Webinaremail45000
Finance Retargetinglinkedin50000
Enterprise Searchgoogle_ads60000

channel = 'email' OR spend > 55000 is false for Spring Launch.

EXAMPLE QUERY
SELECT name FROM marketing.campaigns
WHERE channel = 'email' OR spend > 55000;
Now You Try

Practice this concept

Growth wants users who are either on the Pro plan or located in the US.

Available schema
growth

Prefix tables with growth.table_name.

idcountryplan
growth.users
ColumnType
idinteger
created_attimestamp with time zone
countrytext
channeltext
plantext
activated_attimestamp with time zone
churned_attimestamp with time zone
legacy_user_codetext
query.sql
Beginner business practice

Sign up free to try it on a real business scenario