Cumulative adding with dynamic base in Postgres
问题 I have the following scenario in Postgres (I'm using 9.4.1 ). I have a table of this format: create table test( id serial, val numeric not null, created timestamp not null default(current_timestamp), fk integer not null ); What I then have is a threshold numeric field in another table which should be used to label each row of test . For every value which is >= threshold I want to have that record marked as true but if it is true it should reset subsequent counts to 0 at that point, e.g. Data