Skip to content

Tag: listagg

Returning multiple identical rows in LISTAGG query

I’m using Oracle, and want to connect two tables into one select statement (for a report), and we’re required to concatenate some of the data from one table into a single row – for which I’m expecting to use LISTAGG. Simplified version of the problem: ACCOUNTS table: InitialDate Accoun…

How to use listagg properly with case statements

I am trying to use listagg but I’m getting the wrong output. Normally, I would use each case statement separately, but then how would I use listagg? Table A: Table B: Desired Output: My attempted (wrong) code: Answer Here’s one option, which uses multiple self-joins. lines #1 – 14 represent …

How to use Replace/Substitution function in PL SQL

I’ve a doubt regarding replacing / substituting values in PLSQL. I’ve used listagg to segregate n number of values with each and every value being splitted by comma delimiter. For instance when executing the above query it returns 7digit alpha numeric values. For example ABCD123,EFGH456,IJKL789 Af…