Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VdQfb-00053E-Jf for pgsql-sql@arkaria.postgresql.org; Mon, 04 Nov 2013 20:22:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VdQfa-0002Y2-Tp for pgsql-sql@arkaria.postgresql.org; Mon, 04 Nov 2013 20:22:42 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VdQfZ-0002Xv-Rb for pgsql-sql@postgresql.org; Mon, 04 Nov 2013 20:22:41 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VdQfW-00029Y-Bj for pgsql-sql@postgresql.org; Mon, 04 Nov 2013 20:22:41 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1VdQfU-0001f4-Uw for pgsql-sql@postgresql.org; Mon, 04 Nov 2013 12:22:36 -0800 Date: Mon, 4 Nov 2013 12:22:36 -0800 (PST) From: Diway To: pgsql-sql@postgresql.org Message-ID: <1383596556949-5776903.post@n5.nabble.com> Subject: json and aggregate MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 1.8 (+) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Hi, Why is the following query not working ? select sum((json_array_elements(data)->>'lines')::integer) as test from test2 where id = 2; ERROR: set-valued function called in context that cannot accept a set ('data' is obviously a json datatype) On the other side, this one is OK but I don't like it ;-) select sum(value) from (select (json_array_elements(data)->>'lines')::integer as value from test2 where id = 2) x; Thanks! -- View this message in context: http://postgresql.1045698.n5.nabble.com/json-and-aggregate-tp5776903.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql