InterviewPrepKit

Home / SQL / Query Basics

Find Gmail Customers

easy
Solving tips
  • Use LIKE with the % wildcard to match a substring at the start or end of a value.
  • Anchor the pattern carefully: '%@gmail.com' matches the domain exactly, while '%gmail%' would over-match.
  • % matches any run of characters and _ matches exactly one character.

You are given a customers table and need to identify everyone using a Gmail address for a targeted email campaign.

Schema

CREATE TABLE customers (
  id    INTEGER PRIMARY KEY,
  name  TEXT,
  email TEXT,
  city  TEXT
);

Sample data:

idnameemailcity
1Alice Smith[email protected]Boston
2Bob Jones[email protected]Denver
3Carol White[email protected]Austin
4Dan Brown[email protected]Boston
5Erin Black[email protected]Seattle
6Frank Green[email protected]Miami

Task

Return the id, name, and email of every customer whose email ends with the domain @gmail.com. Order the rows by id in ascending order.

Expected output

idnameemail
1Alice Smith[email protected]
3Carol White[email protected]
5Erin Black[email protected]
Your workspace Not runnable by design — this is your interview scratchpad. Saved on this device.