Streamhub's growth team is running an upsell campaign targeting users on entry-level plans.
Write a query to return the name and current plan of every user on either the starter or free plan.
Assumptions:
- The
userstable contains every account on the Streamhub platform. - The
plancolumn records each user's current subscription tier as one offree,starter,pro, orenterprise.
Output:
- One row per qualifying user, with columns
nameandplan.
Schema · analytics 5 tables
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
name,
plan
FROM
users
WHERE
plan = 'starter'
OR plan = 'free' The shape
Two equality checks joined by OR — a row qualifies for the upsell campaign when its plan matches either of the entry-level tiers.
Clause by clause
SELECT name, plannames the two columns the growth team needs on the audience list: who the user is, and which plan they're sitting on. Returningplanalongsidenamemakes the result self-describing — every row carries the reason it was included.FROM usersreads the users table. Every account on the platform lives here, and the filter narrows the population from there.WHERE plan = 'starter' OR plan = 'free'is the membership test.ORis satisfied when at least one side is true, so astarteruser passes (the first condition is true), afreeuser passes (the second condition is true), and aproorenterpriseuser is dropped because neither side matches.
Why OR and not AND
The two conditions compare the same column to different values. A single row's plan can only ever equal one of them at a time, so writing plan = 'starter' AND plan = 'free' is asking for a value that is simultaneously two different strings. That's impossible, so the AND form would return zero rows. OR is the correct connective whenever a row qualifies by matching any one of several values on the same column.
You practiced using OR to accept rows that match any one of several discrete values. This is the recurring shape of a membership filter — the row qualifies if it falls into any of the listed buckets.