Skip to content
Advertisement

Listagg result binding variable

I hava a this query select LISTAGG(id, ',') WITHIN GROUP (ORDER BY id) as "id_no" from student_all .

It is working but I want to use result in a variable so I wrote this query like this

but it is not working. My error is missing keyword.

Also I wanted to write a function for the testing but same error.I did not created function.

Do you have any idea?

Advertisement

Answer

There are multiple issues with your code.

  • Semicolon is missing at the end of the SELECT statement
  • FETCH clause is not used properly.

I think you are looking for the code to fetch only a few rows and then do LISTAGG. You can use the following code.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement