We have a set of columns within a table we need to concatenate, and we need brackets around the third, fourth, fifth and sixth value, but also need nothing to appear if the column is null.
NVL(PART || '.'|| SECTION ||'(' ||SUB1||')'|| '(' ||SUB2|| ')' || '('||SUB3||')' || '('||SUB4||')', '') as concatenated
Hmmm, I think you want:
select id, (part || '.' || section || (case when sub1 is not null then '(' || sub1 || ')' end) || (case when sub2 is not null then '(' || sub2 || ')' end) || (case when sub3 is not null then '(' || sub3 || ')' end) || (case when sub4 is not null then '(' || sub4 || ')' emd) ) as concatenated from table1;