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 1knApB-0007vp-Vd for pgsql-general@arkaria.postgresql.org; Thu, 10 Dec 2020 01:32:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1knApA-0004Y4-UH for pgsql-general@arkaria.postgresql.org; Thu, 10 Dec 2020 01:32:52 +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 1knApA-0004Xv-Mq for pgsql-general@lists.postgresql.org; Thu, 10 Dec 2020 01:32:52 +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 1knAp8-0006HR-KG for pgsql-general@lists.postgresql.org; Thu, 10 Dec 2020 01:32:52 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 27DFEB1C; Wed, 9 Dec 2020 20:32:48 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 09 Dec 2020 20:32:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=7 loLVMq89lVJoVLjUBLDS3m5ZDOWbmdA7F68Ad+nlTE=; b=cJGAL973OlOi5QSm9 6jsvERz0tqkzpcSs/ZJE3YmQmzFoaiL2lsHuRr3uAbWJ/ScpWCQIf3OuHM9jr9pO njecxbdNk0fEHORnGa50CkQEaLubW1OD4VEOidC4FOLPk+sy3t2VWIzv2trtJrKv BZyqKRSDUEQTkFhGuGGu0jL59kDTnBIaei2VHL7hl2YUGBcraZUAiE559lOXuP6O iCIlIxvvMVxei9+8ZnInpCajeoeDVh1o4iudN60+n02BM96/9rWaVZtD+/HBQ+jr 0dHIYmdCX6/kptwy+zf9KwNFvaSxMTREmXcZiTwyaBllbWjh7xkPViNkAdcmHt95 Z6puA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=7loLVMq89lVJoVLjUBLDS3m5ZDOWbmdA7F68Ad+nl TE=; b=LlUC/xFu6SzRxWqS+kzssqkkuIaqGrWO8iZ0R5bEDwZUYPzY+/vHi9R4F iiNRqfGIVcTrrdzkQCSXXUGYBUqQ1cKxlj8R5rwJmdAfHpLitihyuDXJhZZ+MPbh A5x0+Q7xfI8zxX88l+1MFwBW2XXgdzGsac2wDfHVJUe8l7pCWYUQOymwKXtzfRXD qqFF9sJgg8KHUhtkOxIfsCD8hZeWVbNT3TNBZY9IULYRRd13Jz+9aHmNfmyYS3pk KjTwkixikRfy+D2pZM+xRN577x6aaaFz/rC4EPL5LxXaKjwwiW+KlxI0jaTSiK/D 4HniwIwYfgwf+lpPqD7RSn1G6yS8A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudejledgfeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeevveefveefueegffekkefhgeeiueffgfetueejvdfg hfeujeejhfekjeelgedtgeenucfkphepjeehrddujedvrddurdeileenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghv vghrsegrkhhlrghvvghrrdgtohhm 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 2AFB6108005B; Wed, 9 Dec 2020 20:32:47 -0500 (EST) Subject: Re: sum of numeric column To: avi Singh Cc: pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: <86102209-ad3d-fac9-eee9-8f4906fae86c@aklaver.com> Date: Wed, 9 Dec 2020 17:32:46 -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 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