SQL practice: Arrays: Many Values in One Cell

Chapter 38 · 8 questions · included in full access

  1. Question 1 · easy

    For each product category, collect the product names into an array called products, sorted alphabetically inside the array. Show category too, ordered by category.

    Solve it in your browser
  2. Question 2 · easy

    Turn the list North, South, East, West into four rows, in a column named region. Do not create a table.

    Solve it in your browser
  3. Question 3 · medium

    For 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.

    Solve it in your browser
  4. Question 4 · medium

    List the branch_name of every branch in the North or South region, using = ANY against an array rather than IN. Order by branch_name.

    Solve it in your browser
  5. Question 5 · medium

    Show each region alongside a comma-and-space separated list of its cities, in a column named cities, sorted inside the list. Order by region.

    Solve it in your browser
  6. Question 6 · medium

    Split the string 'North,South,East' on commas and return one row per piece, in a column named region. Order by region.

    Solve it in your browser
  7. Question 7 · hard

    Find 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.

    Solve it in your browser
  8. Question 8 · hard

    You have a table with a tags text[] column and you need to find rows tagged both "urgent" and "export". Which operator does that?

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing