Not Equals
Not Started

Sometimes, we need the inverse of a condition, or cases WHERE a value does not equal something. To do this, we prefix our equals with the "not operator", !=, to invert the condition.

For example, to retrieve a list of Opportunities that are not in the 'Closed Won' stage, we can use the following query:

SELECT Name, StageName, Type FROM Opportunity WHERE StageName != 'Closed Won'



NameStageNameType
Dickenson Mobile GeneratorsQualificationNew Customer
United Oil Office Portable GeneratorsNegotiation/ReviewExisting Customer - Upgrade
Grand Hotels Kitchen GeneratorId. Decision MakersExisting Customer - Upgrade
.........



Let's say you want to look at all the global accounts, excluding those in the United States. 🌍

SELECT Name, AnnualRevenue, BillingCountry FROM Account WHERE BillingCountry != 'United States'

NameAnnualRevenueBillingCountry
Edge Communications139000000Argentina
Burlington Textiles Corp of America350000000France
Pyramid Construction Inc.950000000Egypt
.........



Additionally, let's say we want to find all the Contacts with an Email so we can put together our distribution list. We can do this by looking for Contacts WHERE their Email is not null.

SELECT Name, Email, Title FROM Contact WHERE Email != null

NameEmailTitle
Rose Gonzalezrose@edge.comSVP, Procurement
Sean Forbessean@edge.comCFO
Jack Rogersjrogers@burlington.comVP, Facilities
.........



Similar to our numeric equality comparison, when using the != for numbers, we just specify the value without any single quotes. For example, this query will retrieve all Opportunities that do not have a 100% probability of closing.

SELECT Name, Probability, StageName FROM Opportunity WHERE Probability != 100

NameProbabilityStageName
Dickenson Mobile Generators10Qualification
United Oil Office Portable Generators90Negotiation/Review
Grand Hotels Kitchen Generator60Id. Decision Makers
.........



Challenge

Write a query that retrieves every Account whose Account Source is not Partner Referral. Return the Account's Name and Account Source.