Aggregate Rows Into a JSON Array
Medium
JSON & Semi-structured Data
For each customer return the products they bought as a JSON array sorted alphabetically. Order by customer_id.
Table schema
Orders(customer_id INT, product VARCHAR(20))Sample data
customer_id | product
1 | Pen
1 | Book
2 | Bag
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.