Complete the code to select all user IDs aggregated into an array.
SELECT [1](user_id) FROM users;The ARRAY_AGG function collects values into an array. Here, it gathers all user_id values.
Complete the code to aggregate product names into an array grouped by category.
SELECT category, [1](product_name) FROM products GROUP BY category;ARRAY_AGG collects all product_name values per category into arrays.
Fix the error in the code to aggregate emails into an array.
SELECT ARRAY_AGG[1] FROM contacts;To aggregate unique emails, use ARRAY_AGG(DISTINCT email). The parentheses and DISTINCT keyword are required.
Complete the code to aggregate distinct tags into an array grouped by post ID.
SELECT post_id, ARRAY_AGG[1]tags FROM post_tags GROUP BY post_id;Use ARRAY_AGG(DISTINCT tags) with parentheses and DISTINCT to get unique tags per post.
Fill all three blanks to aggregate user names in uppercase into an array grouped by city.
SELECT city, ARRAY_AGG([1]([2])) AS users FROM users GROUP BY [3];
This query groups users by city and aggregates their names in uppercase using ARRAY_AGG(UPPER(user_name)).