4 回答

TA貢獻1805條經驗 獲得超10個贊
NVL2(expr1,expr2,expr3) 功能:如果參數表達式expr1值為NULL,則NVL2()函數返回參數表達式expr3的值;如果參數表達式expr1值不為NULL,則NVL2()函數返回參數表達式expr2的值。NVL( string1, replace_with) 功能:如果string1為NULL,則NVL函數返回replace_with的值,否則返回string1的值,如果兩個參數都為NULL ,則返回NULL。

TA貢獻1784條經驗 獲得超9個贊

TA貢獻1801條經驗 獲得超16個贊
select wm_concat(name) name from user;--10g寫法
select listagg(name,',') within group (order by name) name from user;--11g寫法

TA貢獻1821條經驗 獲得超6個贊
方法一,使用connect by +sys_connect_by_path :
--測試數據
create table test(col varchar2(10));
insert into test values('a');
insert into test values('b');
insert into test values('c');
--SQL語句:
select ltrim(sys_connect_by_path(col, ','), ',')
from (select col, row_number() over(order by rownum) rn from test t)
where connect_by_isleaf = 1
start with rn = 1
connect by rn = prior rn + 1;
方法二,使用xmltype:
select dbms_lob.substr(rtrim(xmlagg(xmlparse(content col || ',' wellformed))
.getclobval(),
','),
4000,
1)
from test;
另外在10,11版本中也不建議使用wm_concat,這個函數屬于非公開函數,在12c版本中已經失效;
- 4 回答
- 0 關注
- 1729 瀏覽
添加回答
舉報