Tickets Mentioning Key Words
Problem
Table: `support_note`
| Column Name | Type |
|---|---|
| note_ref | varchar |
| body | text |
`note_ref` is the primary key. Each row holds the free-text body of one support ticket.
Count how many tickets contain the word `urgent` and how many contain the word `refund`, where each must appear as a **standalone word** (surrounded by spaces or at the very start/end of the body), not merely as part of a longer word such as 'refundable'. Return two rows with columns `word` and `tally`: first the row for `urgent`, then the row for `refund`.
Tables
Example rows — the live problem includes the full dataset.
| note_ref | body |
|---|---|
| N-1 | Customer flagged this as urgent and asked for a refund of the deposit. |
| N-2 | They want a refund but it is not urgent at all. |
| N-3 | The item is refundable within thirty days, no action needed. |
Expected output
Your answer should return 2 rows with the columns word, tally.
Starter code (SQL)
SELECT *
FROM support_note;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock