create temp table tmp_apps (
id integer
);
create temp table tmp_pos (
tmp_apps_id integer,
position integer
);
insert into tmp_apps
select 1 id union
select 2 id
;
insert into tmp_pos (tmp_apps_id, position)
select 1 tmp_apps_id, 1 as position union all
select 1 tmp_apps_id, 1 as position union all
select 1 tmp_apps_id, 2 as position union all
select 1 tmp_apps_id, 3 as position union all
select 1 tmp_apps_id, 3 as position union all
select 2 tmp_apps_id, 1 as position
;
/*
Expected result:
tmp_apps_id tmp_pos_position
1 1,2
2 1
*/
如何獲得第2逗號分隔,不同tmp_pos.position
每個tmp_apps.id
這是可能的嗎?PostgreSQL的選擇查詢
工作測試用例+1。 *這是*你如何更容易地幫助你。 – 2012-01-29 00:05:52