▸_sqlgym

93. Extract the Email Domain

MediumString Manipulationsubstrinstr

There is no SPLIT_PART in SQLite, so to grab the part of an email after the @ you combine instr and substr. instr(email,'@') returns the 1-based position of the @; everything after it starts one character later.

Task: for each user return id, email, and domain — the substring of email after the @ sign. Use substr(email, instr(email,'@') + 1) (the two-argument substr returns from a start position to the end of the string). Order by id.

Output columns, in order: id, email, domain.

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
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.