Re: trying to do an update a bit confused. - Mailing list pgsql-sql

From Jaime Casanova
Subject Re: trying to do an update a bit confused.
Date
Msg-id c2d9e70e050419160340f7c31d@mail.gmail.com
Whole thread Raw
In response to trying to do an update a bit confused.  ("Joel Fradkin" <jfradkin@wazagua.com>)
List pgsql-sql
On 4/19/05, Joel Fradkin <jfradkin@wazagua.com> wrote:
>
>
>
> update tblcase  set merchandisetotal =
>
> (
>
> COALESCE(( SELECT sum(m.quantity::numeric * m.amount) AS merchandiseamount
>
>            FROM tblmerchandise m
>
>           WHERE m.caseid = tblcase.caseid AND m.clientnum::text =
> tblcase.clientnum::text), 0.0)
>
> )
>
>

Put the coalesce inside the select:
update tblcase  set merchandisetotal =     (SELECT COALESCE(sum(m.quantity::numeric * m.amount),0.0) AS
merchandiseamount       FROM tblmerchandise m      WHERE m.caseid = tblcase.caseid AND m.clientnum::text =
tblcase.clientnum::text)

--
Regards,

DBA* Jaime Casanova
(DBA: DataBase Aniquilator ;)


pgsql-sql by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: tsearch2
Next
From: Mihail Nasedkin
Date:
Subject: Re: Debet-Credit-Balance Calculation