赞
踩
如果需要对ord进行分组,但是num值要在一个格子里:
SELECT ord,string_agg(num||'','-' ORDER BY num) from cx.over_test
group by ord;
select ord, array_agg(num ORDER BY num) from cx.over_test
group by ord;
去重。可以只获取排序号:
select array_agg(distinct ord ORDER BY ord) from cx.over_test;
对于数组的操作,跟java差不多,后面跟序号就可以取值,从1开始:
select ord,(array_agg(num ORDER BY num))[1] from cx.over_test
group by ord;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。