Postgresql 前几行的累积数组?
是否有一个查询会将以前的ID推送到数组中,从而导致:Postgresql 前几行的累积数组?,postgresql,Postgresql,是否有一个查询会将以前的ID推送到数组中,从而导致: id c_array ----------------- 1 {} 2 {1} 3 {1,2} 4 {1,2,3} 像这样试试 select id, array(select l.id from table1 l where l.id< i.id order by id) as c_Arr from table1 i 像这样试试 select id, array(select l.id from table1 l whe
id c_array
-----------------
1 {}
2 {1}
3 {1,2}
4 {1,2,3}
像这样试试
select id, array(select l.id from table1 l where l.id< i.id order by id) as
c_Arr from table1 i
像这样试试
select id, array(select l.id from table1 l where l.id< i.id order by id) as
c_Arr from table1 i
像这样试试
select id, array(select l.id from table1 l where l.id< i.id order by id) as
c_Arr from table1 i
像这样试试
select id, array(select l.id from table1 l where l.id< i.id order by id) as
c_Arr from table1 i
我想您应该使用array_agg aggregate作为窗口函数
SELECT
id,
array_agg(id) OVER (ORDER BY id) AS c_array
FROM the_table
我想您应该使用array_agg aggregate作为窗口函数
SELECT
id,
array_agg(id) OVER (ORDER BY id) AS c_array
FROM the_table
我想您应该使用array_agg aggregate作为窗口函数
SELECT
id,
array_agg(id) OVER (ORDER BY id) AS c_array
FROM the_table
我想您应该使用array_agg aggregate作为窗口函数
SELECT
id,
array_agg(id) OVER (ORDER BY id) AS c_array
FROM the_table
若要获得所需的结果,您需要在无界前置和1前置之间添加不同的帧规范:order by id行。@TomasGreif Good catch。当默认帧规范为时,它不包括当前行。若要获得所需的结果,您需要添加不同的帧规范:在无界前置和1前置之间按id排序。@TomasGreif Good catch。当默认帧规范为时,它不包括当前行。若要获得所需的结果,您需要添加不同的帧规范:在无界前置和1前置之间按id排序。@TomasGreif Good catch。当默认帧规范为时,它不包括当前行。若要获得所需的结果,您需要添加不同的帧规范:在无界前置和1前置之间按id排序。@TomasGreif Good catch。当默认帧规格为时,它不包括当前行。