Oracle 11g: LISTAGG ignores NULL values

select replace(listagg(NVL(col1, '#'), '#') 
within group(order by rownum),'###','##') from table1

you can use the NVL(col1, '#') here you can pass any value instead of null.

HErE is the demo


select substr(listagg('#'||col1) within group (order by rownum),2)
from table1

Prepend the separator before each value (this yields the separator only for NULLs), then aggregate without separator, and strip the leading separator.


Try this way:

select replace(
                listagg(coalesce(col1,'replace'), '#') 
                within group(order by rownum),      
       'replace','') 
from table1

Sql Fiddle Demo