Re: Electricity bill

From: Jonathan Katz <jonathan(dot)katz(at)excoventures(dot)com>
To: stercor(at)gmail(dot)com
Cc: pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: Electricity bill
Date: 2022-06-08 01:42:27
Message-ID: 4F6F634F-7729-4541-B66A-97D34CA839EA@excoventures.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


> On Jun 7, 2022, at 9:39 PM, Theodore M Rolle, Jr. <stercor(at)gmail(dot)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…

Based on your description, what I can offer right now is:

SELECT date_trunc(‘month’, date_col), sum(val_col);

Jonathan

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2022-06-08 01:47:17 Re: Electricity bill
Previous Message Theodore M Rolle, Jr. 2022-06-08 01:39:09 Electricity bill