Reputation: 565
Is there a query that would push previous ids into an array, that would result in:
id c_array
-----------------
1 {}
2 {1}
3 {1,2}
4 {1,2,3}
Upvotes: 0
Views: 93
Reputation: 324761
I think you want to use the array_agg
aggregate as a window function.
SELECT
id,
array_agg(id) OVER (ORDER BY id) AS c_array
FROM the_table
Upvotes: 2
Reputation: 4487
Try Like This
select id, array(select l.id from table1 l where l.id< i.id order by id) as
c_Arr from table1 i
Upvotes: 1