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 1knA8j-0006U5-Ue for pgsql-general@arkaria.postgresql.org; Thu, 10 Dec 2020 00:49:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1knA8i-0002I9-TE for pgsql-general@arkaria.postgresql.org; Thu, 10 Dec 2020 00:49:00 +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 1knA8i-0002I1-29 for pgsql-general@lists.postgresql.org; Thu, 10 Dec 2020 00:49:00 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1knA8f-0005yM-1a for pgsql-general@lists.postgresql.org; Thu, 10 Dec 2020 00:48:59 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id A4F68C7F for ; Wed, 9 Dec 2020 19:48:53 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 09 Dec 2020 19:48:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=q 11v7PKGTIzAekDjhl0OG0w24OU13WCM1Q9Fw2QOSaw=; b=k9in8zWDgQXq/mraB v0q5r1vhWXJOLWFS20XV4MWLqKfDmt3RqnPyACjAx+luj6MB8dWhlAWyQAeEXUte RnaSPYsvzkZBAPnXLyV4z7iIiHVwfuA5OOer1BLyZt3rIDyYsCry87m/00EhwCwE e1o70tav2MPywl6QibolJaOCPiYW6h/ubl6HtR2Ytv1Au807SBeafhGXmPa4Iyfk ob66kMzqbv0Z3qb5YMzNzYZo02OfWOMVLJ2fhnzLlKNepdR0cSWC54cQLCYo1SO4 uNEM2PRIKcLzZ4gJSclZSBnI6BByZzp4KA/c1KsJoc+Mgfwf/RsyJNaVT9twVvk+ 4WAzA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=q11v7PKGTIzAekDjhl0OG0w24OU13WCM1Q9Fw2QOS aw=; b=iWIXvIWdXiJ9UCv+OsWk4TA6z8WikwGKbSSm94u3jLD/75P9FR0v1fKP2 SJzfaH7IpmFJwk2rhlRPfr7AMQUMf2E/YzNqNfPAX6L0dDYzG2Wf9UPv4AfNy6Ow FUb9qm9+QBUSvrRtcG7IPp+k8Lux3fKdszUdDQbA593El9HryRioNxEHEMscH1NZ X3aJ3U9GZASNn9Ul3ZFjc4mT4EF/fkjygSD1FSzTINYxCqNZHL9ToQwJtkdw+izi y98UQJ0DJO8PSEfQqOAPGnp8Y9HBXfLgfrsB37aBxd4dSe6C9LHbXzqG4zIoY0IS 66ZpUXMKCc6zCujQJnh+HdR1qA5bQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudejledgvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtke ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepveevfeevfe eugeffkeekhfegieeufffgteeujedvgffhueejjefhkeejleegtdegnecukfhppeejhedr udejvddruddrieelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.4] (75-172-1-69.tukw.qwest.net [75.172.1.69]) by mail.messagingengine.com (Postfix) with ESMTPA id DB0591080069 for ; Wed, 9 Dec 2020 19:48:52 -0500 (EST) Subject: Re: sum of numeric column To: pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: Date: Wed, 9 Dec 2020 16:48:52 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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