pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: avi Singh <avisingh19811981@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: sum of numeric column
Date: Wed, 9 Dec 2020 17:32:46 -0800
Message-ID: <86102209-ad3d-fac9-eee9-8f4906fae86c@aklaver.com> (raw)
In-Reply-To: <CAETvN5h4LsUR6=pGNdmA8xpzPX0nKc3A7xJfCEaq-nGO-YPN7A@mail.gmail.com>
References: <CAETvN5giG3jerWi_A+n6pRBjUzMm5CU5Pu=axKxV88QFuHQcxg@mail.gmail.com>
	<d13cca9a-1db9-2fe8-b33f-b0b1e26e1bd5@aklaver.com>
	<CAETvN5h4LsUR6=pGNdmA8xpzPX0nKc3A7xJfCEaq-nGO-YPN7A@mail.gmail.com>

On 12/9/20 5:04 PM, avi Singh wrote:
> Thanks for your reply Adrian
> 
> 
> What do you want to do with the array?
> i want to do a sum of the values of numeric array type column e.g. below
> data_numeric
> --------------
>   {2.0}
>   {1.0}

If you are going to have a single element arrays only then why not just 
use a numeric field?

To answer question:

select sum(data_numeric[1]) from some_table;

If you are going to have multi-element arrays then there are more questions:

1) Do you want sum horizontal in array?

2) If 1) then also vertical in column?

3) Do you want sum in 'columns' of arrays?

4) If 3) then what about missing data?

> 
> 
> (4 rows)
> 
> 
> 
> Regards
> 
> 



-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (5+ messages)  latest in thread

Message-ID: <86102209-ad3d-fac9-eee9-8f4906fae86c@aklaver.com>
Permalink:  ../86102209-ad3d-fac9-eee9-8f4906fae86c@aklaver.com/
Also on:    postgresql.org/message-id/86102209-ad3d-fac9-eee9-8f4906fae86c@aklaver.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, avisingh19811981@gmail.com
  Subject: Re: sum of numeric column
  In-Reply-To: <86102209-ad3d-fac9-eee9-8f4906fae86c@aklaver.com>
  References: <CAETvN5giG3jerWi_A+n6pRBjUzMm5CU5Pu=axKxV88QFuHQcxg@mail.gmail.com> <d13cca9a-1db9-2fe8-b33f-b0b1e26e1bd5@aklaver.com> <CAETvN5h4LsUR6=pGNdmA8xpzPX0nKc3A7xJfCEaq-nGO-YPN7A@mail.gmail.com> <86102209-ad3d-fac9-eee9-8f4906fae86c@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox