Re: Window function for get the last value to extend missing rows

2023-05-13 Thread postmaster
Am 12.05.23 um 13:04 schrieb Durumdara: [...] The LAG function seems to be ok, but how to handle if more than two periods are missing? 03:00 10 03:01 NULL 03:02 NULL 03:03 NULL 03:04 11 03:05 13 [...] and how do you think about NULL in first(and second/third) row?

Re: Window function for get the last value to extend missing rows

2023-05-13 Thread Kirk Wolak
On Sat, May 13, 2023 at 2:18 AM Andrew Gierth wrote: > > "Durumdara" == Durumdara writes: > > create table tmp_test_table(mmin,val) >as select o, v > from unnest(array[1,5,NULL,3,NULL,NULL,10,7,NULL,NULL,NULL,4]) >with ordinality as u(v,o); > select * from tmp_te

Re: Window function for get the last value to extend missing rows

2023-05-12 Thread Andrew Gierth
> "Durumdara" == Durumdara writes: Durumdara> I have to make a virtual table which is minute based. Durumdara> I thought I would make a generated temp table Durumdara> (generate_series) and then join these values based on minue. Durumdara> 03:00 10 Durumdara> 03:01 NULL Durum

Re: Window function for get the last value to extend missing rows

2023-05-12 Thread Thorsten Glaser
On Fri, 12 May 2023, GF wrote: >"The SQL standard defines a RESPECT NULLS or IGNORE NULLS option for lead, >lag, first_value, last_value, and nth_value. This is not implemented in >PostgreSQL: the behavior is always the same as the standard's default, >namely RESPECT NULLS". Yeah, THAT caused no

Re: Window function for get the last value to extend missing rows

2023-05-12 Thread GF
On Fri, 12 May 2023 at 13:04, Durumdara wrote: > Dear Members! > > I have a table with temperature measures. > The data is coming from the PLC, but sometimes the period is "slipping", > so the values are not correctly minute based. > > 03:00 10 > 03:02 12 > 03:03 11 > 03:05 13 > >