我正在尝试创建一个SQL查询,该查询可以从表中返回数据以在一行中显示一列的多个值。
例如,这是表格设置:
SEQ ROWSEQNUM ASSISTING_ASSOCIATES 100 2 19332816 100 1 1366344 103 1 12228238 104 1 1366474
我需要查询结果看起来像这样:
SEQ ROWSEQNUM ASSISTING_ASSOCIATES 100 1 1366344; 19332816 103 1 12228238 104 1 1366474
有人有见识吗?
我认为这应该起作用,假设对于每个SEQ值,总是有一行,ROWSEQNUM=1并且要ROWSEQNUM连续增加的值没有间隙。
SEQ
ROWSEQNUM=1
ROWSEQNUM
select seq, min(rowseqnum), max(assoc_list) from ( select seq, rowseqnum, sys_connect_by_path(assisting_associate,';') assoc_list from assoc_table start with rowseqnum=1 connect by seq = prior seq and rowseqnum = prior rowseqnum + 1 ) group by seq