pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: sum of numeric column
Date: Wed, 9 Dec 2020 16:48:52 -0800
Message-ID: <d13cca9a-1db9-2fe8-b33f-b0b1e26e1bd5@aklaver.com> (raw)
In-Reply-To: <CAETvN5giG3jerWi_A+n6pRBjUzMm5CU5Pu=axKxV88QFuHQcxg@mail.gmail.com>
References: <CAETvN5giG3jerWi_A+n6pRBjUzMm5CU5Pu=axKxV88QFuHQcxg@mail.gmail.com>

On 12/9/20 4:46 PM, avi Singh wrote:
> I have a table structure and want to do a sum of column type i.e 
> numeric. How can I do it ? when i try sum function i get this error

You don't have a numeric type you have a numeric array type.

> 
> ERROR:  function sum(numeric[]) does not exist

Hence the error above.

> 
> Can anyone please help me with this ?

What do you want to do with the array?

> 
>             Column           |           Type           | Collation | 
> Nullable | Default
> ----------------------------+--------------------------+-----------+----------+---------
>   grid_id                    | bigint                   |           | 
> not null |
>   as_of_date                 | date                     |           | 
> not null |
>   cell_id                    | bigint                   |           | 
> not null |
>   last_event_timestamp_local | timestamp with time zone |           |   
>         |
>   last_event_id              | bigint                   |           |   
>         |
>   column_id                  | bigint                   |           |   
>         |
>   column_name                | character varying(50)    |           |   
>         |
>   row_id                     | bigint                   |           |   
>         |
>   data_type_id               | smallint                 |           |   
>         |
>   data_numeric               | numeric[]                |           |   
>         |
>   data_string                | character varying[]      |           |   
>         |
> 
> e.g. of values in numeric type column
> 
>   data_numeric
> --------------
>   {2.0}
>   {1.0}
> 
> Regards
> Prabhjot


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (5+ messages)  latest in thread

Message-ID: <d13cca9a-1db9-2fe8-b33f-b0b1e26e1bd5@aklaver.com>
Permalink:  ../d13cca9a-1db9-2fe8-b33f-b0b1e26e1bd5@aklaver.com/
Also on:    postgresql.org/message-id/d13cca9a-1db9-2fe8-b33f-b0b1e26e1bd5@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
  Subject: Re: sum of numeric column
  In-Reply-To: <d13cca9a-1db9-2fe8-b33f-b0b1e26e1bd5@aklaver.com>
  References: <CAETvN5giG3jerWi_A+n6pRBjUzMm5CU5Pu=axKxV88QFuHQcxg@mail.gmail.com> <d13cca9a-1db9-2fe8-b33f-b0b1e26e1bd5@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