▸_sqlgym

101. Case-Insensitive Name Sort

MediumOrderingCOLLATE NOCASEgroup_concatDeterministic order

By default SQLite sorts text by byte value, so all uppercase letters sort before lowercase ('Zoe' before 'amy'). COLLATE NOCASE makes comparisons case-insensitive, so names interleave the way a human expects. Because NOCASE treats 'Amy' and 'amy' as equal, you add a deterministic tiebreak (here the original name and id) to keep the order total.

The people table has mixed-case names.

Task (two parts):

  1. Return the people sorted case-insensitively by name, with a stable tiebreak.
  2. Also return a single comma-separated roster of all names in that same case-insensitive order via group_concat.

First query returns columns id, name ordered case-insensitively by name, then by id ascending. (The roster is shown in the approach for reference; the graded result is the first query.)

Return columns id, name, ordered by name COLLATE NOCASE ascending, then id ascending.

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.
← PrevListNext →