Home>
When there is a table like the following,
To extract the difference from the previous day (get the previous record, not the actual date)
What should I do?
* Table definition *
create table uriage
(date DATE NOT NULL,
price double precision);
date price
2010-01-01 100
2010-01-02 120
2010-01-05 130
Postgresql 11 is assumed.
Trends
lag is for the purpose.
In practice, you will also usepartition by.