Search Artists by Name Pattern
A customer is looking for bands that start with "The" (like "The Beatles", "The Rolling Stones", etc.). You need to...
Cut, combine and match text values that arrive in the wrong shape.
Text columns rarely arrive in the shape a report needs: names come combined, emails hide the domain, product codes carry a prefix. SQL string functions cut and rebuild those values in place, with SUBSTR and POSITION for slicing, concatenation for joining fields, LIKE for simple pattern matching and regular expressions when the pattern is not simple. These questions cover the parsing and matching problems that come up in interviews and in day-to-day cleanup work.
A customer is looking for bands that start with "The" (like "The Beatles", "The Rolling Stones", etc.). You need to...
You're preparing data for a banner display system that only accepts uppercase text. Convert all artist names to...
The mailing system needs customer full names in a single field. Combine the first and last name columns into one "Full...
The marketing analytics team wants to analyze which email providers customers use (gmail.com, yahoo.com, etc.). Extract...
Create a report combining high-value invoices (over $15) and recent invoices (from 2013). Use UNION ALL to keep all...
The customer success team wants a quick contact list of customers from North America, showing each as a single readable...
The analytics team wants a quick view of customer email providers, alongside each customer's full name and an...
A community radio station wants to surface love-themed tracks of standard radio length, restricted to those with a...
Classic RFM segmentation: score every customer on Recency (R), Frequency (F), and Monetary (M), then assign a segment...
FAQ
Short answers to what people get stuck on most. Tap a question to expand it.
Split on a delimiter with SPLIT_PART, or slice with SUBSTR and POSITION.
SELECT email,
SPLIT_PART(email, '@', 2) AS domain,
SUBSTR(email, 1, POSITION('@' IN email) - 1) AS username
FROM users;Use LIKE for simple patterns. Use a regular expression when you need character classes or repeats.
SELECT *
FROM customers
WHERE phone ~ '^[0-9]{10}$'
OR name ILIKE 'a%';In PostgreSQL, joining any value with NULL using || gives NULL.
SELECT CONCAT_WS(' ', first_name, middle_name, last_name) AS full_name
FROM users;Track your streak & earn XP
Sign up free to unlock your progress dashboard, daily streaks, and leaderboard ranking.
10 role-based tests for Data Analysts, SQL Developers & Data Engineers with instant scorecards.