SQL practice: Arrays: Many Values in One Cell
Chapter 38 · 8 questions · included in full access
Question 1 · easy
Solve it in your browserFor each product category, collect the product names into an array called products, sorted alphabetically inside the array. Show category too, ordered by category.
Question 2 · easy
Solve it in your browserTurn the list North, South, East, West into four rows, in a column named region. Do not create a table.
Question 3 · medium
Solve it in your browserFor each category show the category and how many products it has, using an array function rather than COUNT. Name the count how_many, ordered by category.
Question 4 · medium
Solve it in your browserList the branch_name of every branch in the North or South region, using = ANY against an array rather than IN. Order by branch_name.
Question 5 · medium
Solve it in your browserShow each region alongside a comma-and-space separated list of its cities, in a column named cities, sorted inside the list. Order by region.
Question 6 · medium
Solve it in your browserSplit the string 'North,South,East' on commas and return one row per piece, in a column named region. Order by region.
Question 7 · hard
Solve it in your browserFind every branch whose region array — built as a one-element array from its region column — overlaps with North or East. Show branch_name and region, ordered by branch_name.
Question 8 · hard
Solve it in your browserYou have a table with a tags text[] column and you need to find rows tagged both "urgent" and "export". Which operator does that?
These questions are part of full access.
The first chapters of every track are free. Full access is a one-time payment.
See pricing