SQL NOT

Flips a condition's truth value — everything that WOULD have matched now gets excluded, and vice versa.

What & Why

NOT negates whatever condition follows it. NOT channel = 'google_ads' keeps every row where that condition is false.

See How It Works

BUSINESS QUESTION

Campaigns outside the google_ads channel.

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 not check each rowRow 1 of 4
-- checking Spring Launch: NOT google_ads = google_ads?FALSE — dropped
namechannel
Spring Launchgoogle_ads
Retention Webinaremail
Finance Retargetinglinkedin
Enterprise Searchgoogle_ads

NOT channel = 'google_ads' is false for Spring Launch.

EXAMPLE QUERY
SELECT name FROM marketing.campaigns
WHERE NOT channel = 'google_ads';
Now You Try

Practice this concept

Marketing wants campaigns that are not paused.

Available schema
marketing

Prefix tables with marketing.table_name.

namestatuschannel
marketing.campaigns
ColumnType
idinteger
nametext
channeltext
spendnumeric
start_datedate
end_datedate
statustext
target_segmenttext
legacy_idtext
query.sql
Beginner business practice

Sign up free to try it on a real business scenario