有数据如下:
11:29:27 scott@ORCL> select sn, random_string st from tb;
SN ST
---------- --------------------------------------------------
1 T2
2 OG
3 G4
4 7H
5 IM
6 JK
7 UI
8 H0
9 BK
10 FK
11 L1
12 HR
13 03
14 3O
15 W5
16 K1
17 WO
18 KE
19 6D
20 78
21 RB
22 3B
23 1E
24 R0
25 B6
26 KM
要求查询结果如下显示,st的值五个一组显示一行:
ST
------------------
T2,OG,G4,IM,7H
JK,UI,H0,FK,BK
L1,W5,3O,HR,03
K1,KE,78,6D,WO
RB,B6,R0,1E,3B
KM
语句如下:
11:31:57 scott@ORCL> select WMSYS.WM_CONCAT(random_string) st
14:32:08 2 from (select sn-1 sn ,random_string from tb)
14:32:08 3 group by trunc(sn/5);
ST
--------------------------------------------------
T2,OG,G4,IM,7H
JK,UI,H0,FK,BK
L1,W5,3O,HR,03
K1,KE,78,6D,WO
RB,B6,R0,1E,3B
KM
11:29:27 scott@ORCL> select sn, random_string st from tb;
SN ST
---------- --------------------------------------------------
1 T2
2 OG
3 G4
4 7H
5 IM
6 JK
7 UI
8 H0
9 BK
10 FK
11 L1
12 HR
13 03
14 3O
15 W5
16 K1
17 WO
18 KE
19 6D
20 78
21 RB
22 3B
23 1E
24 R0
25 B6
26 KM
要求查询结果如下显示,st的值五个一组显示一行:
ST
------------------
T2,OG,G4,IM,7H
JK,UI,H0,FK,BK
L1,W5,3O,HR,03
K1,KE,78,6D,WO
RB,B6,R0,1E,3B
KM
语句如下:
11:31:57 scott@ORCL> select WMSYS.WM_CONCAT(random_string) st
14:32:08 2 from (select sn-1 sn ,random_string from tb)
14:32:08 3 group by trunc(sn/5);
ST
--------------------------------------------------
T2,OG,G4,IM,7H
JK,UI,H0,FK,BK
L1,W5,3O,HR,03
K1,KE,78,6D,WO
RB,B6,R0,1E,3B
KM