Re: Windowing ?
Andreas Kretschmer <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.sql |
|---|---|
| Message-ID | <[email protected]> |
Am 11.12.2017 um 18:09 schrieb Olivier Leprêtre: > > Hi, > > I have a table describing sort of ordered road segments and their > associated weight. I would like to calculate weight deltas between two > consecutive segments. Problem is to substract previous from current > row and reuses result as input for the next row. > You can use the lag() - function. select ..., lag(weight) over (partition by road order by segment) ... Regards, Andreas -- 2ndQuadrant - The PostgreSQL Support Company. www.2ndQuadrant.com