String aggregation with STRING_AGG
📖 Scenario: You are managing a small bookstore database. You want to list each author along with all the book titles they have written, combined into a single string for easy reading.
🎯 Goal: Build a query that uses STRING_AGG to combine book titles for each author into one string, separated by commas.
📋 What You'll Learn
Create a table called
books with columns author (text) and title (text).Insert the exact data rows provided.
Write a query that uses
STRING_AGG to group book titles by author.Order the aggregated titles alphabetically within the string.
💡 Why This Matters
🌍 Real World
Combining multiple related text entries into one string is common in reports, summaries, and user interfaces where concise display is needed.
💼 Career
Database developers and analysts often use STRING_AGG to prepare readable aggregated data for dashboards, reports, and data exports.
Progress0 / 4 steps