简体   繁体   中英

Issue in listagg

I have to concatenate 2 columns and put the value. but the problem is even if both the values are null it is still giving (:) as per below syntax. is there anyway we can remove column in the output if both values are null.

listagg(AP.ISSUE_ID||':'||ISS.ISSUE_DESCRIPTION ,'; ') within group(order by AP.ISSUE_ID||':'||ISS.ISSUE_DESCRIPTION) DESCRIPTION,

If you want to ignore a column in listagg() , set the value to NULL . In this case, Oracle accepts NULL values for string concatenation. So, let's do a test after the concatenation:

listagg(nullif(AP.ISSUE_ID ||| ':' || ISS.ISSUE_DESCRIPTION, ':'),'; ')
    within group (order by AP.ISSUE_ID || ':'|| ISS.ISSUE_DESCRIPTION) as DESCRIPTION,
AP.ISSUE_ID || nvl2(AP.ISSUE_ID || ISS.ISSUE_DESCRIPTION, ':' || ISS.ISSUE_DESCRIPTION, null)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM