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 Smithalice@gmail.comBoston
2Bob Jonesbob@yahoo.comDenver
3Carol Whitecarol@gmail.comAustin
4Dan Browndan@company.orgBoston
5Erin Blackerin.g@gmail.comSeattle
6Frank Greenfrank@gmailx.comMiami

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 Smithalice@gmail.com
3Carol Whitecarol@gmail.com
5Erin Blackerin.g@gmail.com
Your workspace Not runnable by design — this is your interview scratchpad. Saved on this device.