Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nykiQ-0003uD-W8 for pgsql-sql@arkaria.postgresql.org; Wed, 08 Jun 2022 01:42:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nykiP-00054Y-R7 for pgsql-sql@arkaria.postgresql.org; Wed, 08 Jun 2022 01:42:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nykiP-00054O-Dz for pgsql-sql@lists.postgresql.org; Wed, 08 Jun 2022 01:42:33 +0000 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nykiN-0008WQ-BC for pgsql-sql@lists.postgresql.org; Wed, 08 Jun 2022 01:42:32 +0000 Received: by mail-qk1-x72c.google.com with SMTP id a184so11002854qkg.5 for ; Tue, 07 Jun 2022 18:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=excoventures-com.20210112.gappssmtp.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=TlsvhkM031NIpG3/VyuYV4pXQgKax7/UoIs5TydWJ+s=; b=VDpdzTaqMtkpL8knSw3jBj3Mg+bvoPPVH7hRi+YsLkRRyn/A8AsKzyCq4Hdc8Dxt2V V2FzHFNuLXd7CIoXtmVaw3JZZMmtZSNo5X3BQG0R5JsoHJwsfOwabsvphpNcBMvh28S+ InAiaJ/wpf+T5OFBBPv+vPk6yqrjfXQb+8qiPOtiZk3jq5U7YMiCk92Y/VAbF1pKVyKB EfyrzIInNsosySu6uSd063XCHS72ePP32JTwlYz/lFUQVSL7ON+9+DrweJvQhi4kiim4 hrU7S8MSlU5yiIcyYv20f8VJJAdOKeTgYvCa+p6TB7aLM8iRsGx9w9aZ2f+mNZc7lAUY mjnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=TlsvhkM031NIpG3/VyuYV4pXQgKax7/UoIs5TydWJ+s=; b=eNtJnEezHYTX+SZEkHquzltiZcrAXZll2mGBqvHVtCCnczITca0qqPj9Kbg9/QMmwt GGDhgXH03fQo7WXPqgu07iubmBGr63/YkKZHN91gZvX+p/04t2JTWdvsQoiJOshq7U+U wD+hdX7CWcVGL0TZi4Pm4uZCrOLlGora5oWJP+SoOYcAFOXOZuTV02YnUrC7zedr0bJ8 WHEYa+9d3jjpgyvbT9jshPnKU23EmSXJaUif3BjvkGi5TAetTT1y0KOiA7Zb8DgUqyxe EH46qON8skGWC9tvVZ4q1818brO+6T/+Gib11KyS8lwGT52m95PqrDBMeVYXKBxYVlTb OsSw== X-Gm-Message-State: AOAM5313Z5UVnPYD0xwvcJpiHTho2iHgZ06t6B0F4t+zdUQ+Gt8Lzvmq n5V4ilew///YyqT9UgQEdrtx3A== X-Google-Smtp-Source: ABdhPJyTP0D3hsyxCJcnnlmH5Vh/6VwdS9iWxLXVCZ2feyVIVCExsmp3qDjlSh40BmAU2bD/3QHjzg== X-Received: by 2002:a05:620a:2291:b0:6a6:ca30:b6e5 with SMTP id o17-20020a05620a229100b006a6ca30b6e5mr7121723qkh.74.1654652549212; Tue, 07 Jun 2022 18:42:29 -0700 (PDT) Received: from smtpclient.apple ([52.119.84.106]) by smtp.gmail.com with ESMTPSA id f2-20020a05620a408200b006a6ab8f761csm9732543qko.62.2022.06.07.18.42.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jun 2022 18:42:28 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.60.0.1.1\)) Subject: Re: Electricity bill From: Jonathan Katz In-Reply-To: Date: Tue, 7 Jun 2022 21:42:27 -0400 Cc: pgsql-sql Content-Transfer-Encoding: quoted-printable Message-Id: <4F6F634F-7729-4541-B66A-97D34CA839EA@excoventures.com> References: To: stercor@gmail.com X-Mailer: Apple Mail (2.3693.60.0.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Jun 7, 2022, at 9:39 PM, Theodore M Rolle, Jr. = wrote: >=20 > 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=E2=80=99 usage? = This requires retrieving two rows to compute the number of days=E2=80=A6 Based on your description, what I can offer right now is: SELECT date_trunc(=E2=80=98month=E2=80=99, date_col), = sum(val_col); Jonathan=