Sv: Re: Difficulties with LAG-function when calculating overtime - Mailing list pgsql-sql

From Andreas Joseph Krogh
Subject Sv: Re: Difficulties with LAG-function when calculating overtime
Date
Msg-id VisenaEmail.4c.51bde41e996a86d1.1672cc0ac94@tc7-visena
Whole thread Raw
In response to Re: Difficulties with LAG-function when calculating overtime  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Sv: Sv: Re: Difficulties with LAG-function when calculatingovertime  (Andreas Joseph Krogh <andreas@visena.com>)
List pgsql-sql
På mandag 19. november 2018 kl. 17:08:57, skrev David G. Johnston <david.g.johnston@gmail.com>:
On Mon, Nov 19, 2018 at 6:24 AM Andreas Joseph Krogh <andreas@visena.com> wrote:
Anyone has a clever way to solve this kinds of issues and craft a query which produces the desired result as in the table above?
 
Thinking in terms of theory - you need to calculate the first row and then calculate the next row using data from the first row.  Then calculate the third row using data from the second row (you might need to carry-forward some value from the first row so that the third row can see them...).  That sounds like the algorithm for iteration which is implemented in SQL via "WITH RECURSIVE".
 
David J.
 
Yea, I kind of figured RECURSIVE CTE was the way foreward...
If anyone has got this working, give me a tip:-)
 
--
Andreas Joseph Krogh

pgsql-sql by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Difficulties with LAG-function when calculating overtime
Next
From: Andreas Joseph Krogh
Date:
Subject: Sv: Sv: Re: Difficulties with LAG-function when calculatingovertime