48. Tags Per Post (Ordered List)
MediumAggregationgroup_concatordered aggregationGROUP BY
group_concat(x, sep) stitches the values in a group into a single delimited string. To make the output deterministic you must control the order the values are concatenated in.
Task: for each post_id, build a comma-separated string of its tag names, sorted alphabetically within the post.
Return columns post_id, tags where, for example, a post tagged sql, data, db becomes data,db,sql (comma, no spaces). Order the result rows by post_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· SQLite · runs in your browser
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.