Convert Yes/No answers to true, false or null (gym)
The marketing opt-in column mixes Yes, Y, no, N, blanks and nulls. Turn it into a proper true/false column.
- Level
- beginner
- Time
- ~7 min
- Task
- Build the query
- Access
- Pro
Checking your access…
About this exercise
What you'll practise
Build a logical column from inconsistent text, keeping 'no answer' distinct from 'no'.
The scenario, sample data, step list, hints and solution open with Pro. Grading checks your query against hidden data as well as the visible sample, so a query that only fits the sample doesn't pass.
Input
- Contacts (table)
- ContactID: text
- Name: text
- OptIn: text (nullable)
Expected output columns
ContactID (text), Name (text), Marketing OK (logical (some rows null))