Skip to Main Content

Write Great SQL Office Hours

Free tips and training every month! Subscribe for reminders and more from Office Hours. FAQ

Header container

October 04, 2022

13:00 UTC   Start Times Around the World

Subscribe to be notified of changes to sessions and give us feedback!

Having trouble watching the video on this page? Open the video in your browser.

Description

How to concatenate rows into a comma-separated list with LISTAGG
Often you need to combine rows into a single comma-separated list. You can do this in Oracle Database with the SQL standard function LISTAGG.

Watch the recording to learn how to use LISTAGG to concatenate values. Highlights include:

- 04:00 LISTAGG syntax
- 05:40 GROUP BY vs PARTITION BY (aggregate vs analytic functions)
- 10:00 Why WITHIN GROUP syntax
- 14:10 Demo of LISTAGG
- 24:30 Ways to create a "running total" or "sliding window" of CSV values
- 31:50 Handling ORA-1489 errors with LISTAGG
- 41:30 Demo of handling ORA-1489 errors
- 47:50 Demo of ways to deduplicate values in the return string
- 54:50 Recap

Get the scripts https://bit.ly/SQL-ATOH-LISTAGG
Learn SQL for free http://bit.ly/learn-sql-free-dfd-f

Your Experts

  • #SELECTION#
    Chris Saxon

    Chris Saxon   

    Chris Saxon is an Oracle Developer Advocate and quizmaster on Dev Gym. His job is to help you get the best out of the Oracle Database and have fun with SQL! He's also part of the answer team on Ask TOM and creates YouTube videos at The Magic of SQL channel.
    #MISC#
    #ACTIONS#