如何在Oracle 10g中根据指定的列将n条记录合并到一条记录中?

时间:2015-08-28 14:05:02

标签: sql oracle oracle10g

表:

ORA-00923: FROM keyword not found where expected

COL_3订购。

我想得到这个:

SELECT id, min(date) as from, max(date) as to
FROM cal
GROUP BY id

任何意见或建议将不胜感激。 感谢。

纯SQL脚本,请。

更新 我在下面的答案是针对Oracle 11的,但在Oracle 10g中出错:

FB.Login ("public_profile, user_photos, email", AuthCallBack);

对于Oracle 10g,解决方案是什么?
感谢。

1 个答案:

答案 0 :(得分:0)

对于Oracle 11,请使用:

select col_1
     , listagg(col_2, ', ') within group (order by col_3) as col_new
from tbl_tmp
group by col_1;

Run here : SQL Fiddle

Refrence:https://stackoverflow.com/questions/17501418/oracle-string-aggregation