Re: Create loop in postgresql - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: Create loop in postgresql
Date
Msg-id 5044F6CB.3050503@iol.ie
Whole thread Raw
In response to Re: Create loop in postgresql  (Robert Buckley <robertdbuckley@yahoo.com>)
List 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@iol.ie


pgsql-general by date:

Previous
From: Robert Buckley
Date:
Subject: Re: Create loop in postgresql
Next
From: Raymond O'Donnell
Date:
Subject: Re: Create loop in postgresql