public inbox for [email protected]  
help / color / mirror / Atom feed
From: Jonathan Katz <[email protected]>
To: [email protected]
Cc: pgsql-sql <[email protected]>
Subject: Re: Electricity bill
Date: Tue, 7 Jun 2022 21:42:27 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAPDmd-CjfhW5pSkthOGmb1rDpznDWYOetrhVh1gcquwQM9n5eA@mail.gmail.com>
References: <CAPDmd-CjfhW5pSkthOGmb1rDpznDWYOetrhVh1gcquwQM9n5eA@mail.gmail.com>


> On Jun 7, 2022, at 9:39 PM, Theodore M Rolle, Jr. <[email protected]> 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




view thread (5+ messages)  latest in thread

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: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Electricity bill
  In-Reply-To: <[email protected]>

* 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