91. Clean Phone Numbers with replace
EasyString Manipulationreplace
replace(s, find, with) swaps every occurrence of a substring. Nesting replace calls lets you strip several unwanted characters in one expression.
Task: for each contact return id, the original phone, and clean — the phone number with spaces, dashes (-) and parentheses removed, leaving only digits. Apply replace four times (remove ' ', '-', '(', ')'). Order by id.
Output columns, in order: id, phone, clean.
Tables
Loading schema…
Expected outputrows must come back in this order
Computing expected output…
This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases — 5test cases in all. A sloppy query that only fits the example won't pass.
SQL· SQLite · runs in your browser
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.