From: | Raymond O'Donnell <rod(at)iol(dot)ie> |
---|---|
To: | Robert Buckley <robertdbuckley(at)yahoo(dot)com> |
Cc: | salah jubeh <s_jubeh(at)yahoo(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Create loop in postgresql |
Date: | 2012-09-03 18:28:27 |
Message-ID: | 5044F6CB.3050503@iol.ie |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 03/09/2012 18:30, Robert Buckley wrote:
> Now even stranger is that I can´t update a column with the query.
>
> Update energie.tennet_auswertung_2010 set "Test"=(
>
> SELECT round(100*ges_kw_zgb/total.totalsum, 2) from
> energie.tennet_auswertung_2010,
> (select sum(ges_kw_zgb) totalsum From energie.tennet_auswertung_2010) as
> total
> );
>
> ERROR: more than one row returned by a subquery used as an expression
The answer's in the error message - the subquery is returning more than
one row. If you're using a subquery as an expression to be used to
update the column, then it can only return one row - otherwise which row
should be used for the update?
Try running the subquery on its own, and play with it until you get a
single value.
Ray.
--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie
From | Date | Subject | |
---|---|---|---|
Next Message | Raymond O'Donnell | 2012-09-03 18:29:33 | Re: Create loop in postgresql |
Previous Message | Robert Buckley | 2012-09-03 17:42:47 | Re: Create loop in postgresql |