Sv: Re: Difficulties with LAG-function when calculating overtime

From: Andreas Joseph Krogh <andreas(at)visena(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Sv: Re: Difficulties with LAG-function when calculating overtime
Date: 2018-11-19 16:20:23
Message-ID: VisenaEmail.4c.51bde41e996a86d1.1672cc0ac94@tc7-visena
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

På mandag 19. november 2018 kl. 17:08:57, skrev David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com <mailto:david(dot)g(dot)johnston(at)gmail(dot)com>>:
On Mon, Nov 19, 2018 at 6:24 AM Andreas Joseph Krogh <andreas(at)visena(dot)com
<mailto:andreas(at)visena(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Joseph Krogh 2018-11-19 16:49:22 Sv: Sv: Re: Difficulties with LAG-function when calculating overtime
Previous Message David G. Johnston 2018-11-19 16:08:57 Re: Difficulties with LAG-function when calculating overtime