pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jaime Casanova <systemguards@gmail.com>
To: Joel Fradkin <jfradkin@wazagua.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: trying to do an update a bit confused.
Date: Tue, 19 Apr 2005 18:03:35 -0500
Message-ID: <c2d9e70e050419160340f7c31d@mail.gmail.com> (raw)
In-Reply-To: <000001c544e8$ef28d820$797ba8c0@jfradkin>
References: <000001c544e8$ef28d820$797ba8c0@jfradkin>

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 ;)



view thread (4+ messages)

Message-ID: <c2d9e70e050419160340f7c31d@mail.gmail.com>
Permalink:  ../c2d9e70e050419160340f7c31d@mail.gmail.com/
Also on:    postgresql.org/message-id/c2d9e70e050419160340f7c31d@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: systemguards@gmail.com, jfradkin@wazagua.com
  Subject: Re: trying to do an update a bit confused.
  In-Reply-To: <c2d9e70e050419160340f7c31d@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox