Helix Systems' CRM team is pulling a list of customer-facing roles — anyone whose title mentions an Account function.
Write a query to return the ID, name, and title of every employee whose title contains the word Account, regardless of capitalization.
Assumptions:
- The
employeestable has one row per employee with anid, aname, and atitle. - A qualifying employee has a
titlethat containsaccountsomewhere in the string, with case ignored.
Output:
- One row per qualifying employee, with columns
id,name, andtitle.
Schema · hr 4 tables
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
id,
name,
title
FROM
employees
WHERE
title ILIKE '%account%' The shape
ILIKE '%account%' is case-insensitive substring matching. The leading and trailing % wildcards let the word account sit anywhere inside the title, and ILIKE (instead of LIKE) folds the case on both sides of the comparison so Account Executive matches the same as account executive would.
Clause by clause
SELECT id, name, titlereturns the three columns the CRM list needs. Showing the matchedtitlealongside the ID and name lets the reader see why each row qualified.FROM employeesreads the employee roster.WHERE title ILIKE '%account%'keeps only the rows whose title contains the substringaccountsomewhere, with capitalization ignored. The two%wildcards anchor nothing, so the match can occur at the start, middle, or end of the title.
Why this and not LIKE '%Account%'
LIKE is case-sensitive. LIKE '%Account%' would catch Account Executive but miss account manager or ACCOUNT REP if either spelling slipped into the table. The prompt says capitalization should be ignored, which is exactly what ILIKE was added to the language to do. Writing it as LIKE plus LOWER(title) works too, but ILIKE is the single-word spelling for the same intent.
You practiced ILIKE '%pattern%' — case-insensitive substring matching, the standard tool for free-text searches that should not be tripped by capitalization.