先查看所用到表的內容
select * from yhb;

期望效果
將times為1的isdropout列的字符串連接起來
isdropout times
是,否,是 1
1.用wmsys.wm_concat(exp1)函數
sql語句如下:
select wmsys.wm_concat(a.isdropout) isdropout from yhb a where a.times=1;

注意,當exp1中的內容很長時,會出現字符串長度太大的錯誤,此時需要改用其它方式,如下
2.用sys.stragg(exp1)函數
select sys.stragg(a.isdropout) isdropout from yhb a where a.times=1;

從結果可看出,sys.stragg(exp1)函數得到的結果只是把字符串簡單拼接起來,中間沒有分隔符,所以需要加工一下
select trim(both ',' from sys.stragg(to_char(a.isdropout)||NVL2(a.isdropout, ',', ''))) as isdropout from yhb a where a.times=1;

其中trim是為了去除末端的,號,NVL2(expr1,expr2,expr3)函數作用如下
功能:oracle中常用函數,如果參數表達式expr1值為NULL,則NVL2()函數返回參數表達式expr3的值;如果參數表達式expr1值不為NULL,則NVL2()函數返回參數表達式expr2的值。
注意:oracle引用字符串的時候用單引號,如NVL2(a.isdropout, ',', ''),不能用雙引號
做個小推廣:程序員經常久坐,頸椎毛病比較多,特別推薦ventry頸椎保健枕
