agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Andreas Joseph Krogh <andreas@visena.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-sql <pgsql-sql@lists.postgresql.org>
Subject: Sv: Re: Difficulties with LAG-function when calculating overtime
Date: Mon, 19 Nov 2018 17:20:23 +0100 (CET)
Message-ID: <VisenaEmail.4c.51bde41e996a86d1.1672cc0ac94@tc7-visena> (raw)
In-Reply-To: <CAKFQuwZjrGG5gtakGN7QMCgCZYYVcCUwXAWmvqdxvi_DbuK8Vw@mail.gmail.com>
På mandag 19. november 2018 kl. 17:08:57, skrev David G. Johnston <
david.g.johnston@gmail.com <mailto:david.g.johnston@gmail.com>>:
On Mon, Nov 19, 2018 at 6:24 AM Andreas Joseph Krogh <andreas@visena.com
<mailto: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
Message-ID: <VisenaEmail.4c.51bde41e996a86d1.1672cc0ac94@tc7-visena>
Permalink: ../VisenaEmail.4c.51bde41e996a86d1.1672cc0ac94@tc7-visena/
Also on: postgresql.org/message-id/VisenaEmail.4c.51bde41e996a86d1.1672cc0ac94@tc7-visena
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: andreas@visena.com, david.g.johnston@gmail.com, pgsql-sql@lists.postgresql.org
Subject: Re: Sv: Re: Difficulties with LAG-function when calculating overtime
In-Reply-To: <VisenaEmail.4c.51bde41e996a86d1.1672cc0ac94@tc7-visena>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox