Re: Electricity bill

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Electricity bill
Дата
Msg-id CAKFQuwaY-zeoWkJwqDP6TDZnowdif2AZsT28+-SA2OWc8KXKTA@mail.gmail.com
обсуждение исходный текст
Ответ на Electricity bill  ("Theodore M Rolle, Jr." <stercor@gmail.com>)
Ответы Re: Electricity bill
Список pgsql-sql
On Tue, Jun 7, 2022 at 6:39 PM Theodore M Rolle, Jr. <stercor@gmail.com> wrote:
I'm putting in YYYY-MM-DD dates of electricity bills and would like to not have starting and ending dates in the same row. Only ending date.
Will someone show me the SQL to compute the months’ usage? This requires retrieving two rows to compute the number of days...

You can use a window function called lead (or lag) to retrieve a value from the next (previous) row and associate it with the current row.

David J.

В списке pgsql-sql по дате отправления:

Предыдущее
От: Jonathan Katz
Дата:
Сообщение: Re: Electricity bill
Следующее
От: "Theodore M Rolle, Jr."
Дата:
Сообщение: Fwd: Electricity bill