pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shaun Watts <SWatts@computer-systems.com>
To: pgsql-sql@postgresql.org
Subject: selecting problems
Date: Fri, 31 Oct 2003 14:19:49 -0500
Message-ID: <6A1C87CA83BA8C419B1262B3728B12D102D435@csiserv1.computer-systems.com> (raw)


What I am trying to do is select all the rows out of the categories
table (see below) and select the sum of j_amount out of the judgment
table.  Right now it is only returning the categories that are in the
judgment table.  I want it to return those fields with the amounts out
of the judgment table, but also the all the other categories from the
categories table with 0 as there amount.  Does anyone have a
suggestion.

select ca_code,ca_desc,sum(j_amount) as sum_amt,ca_dis_cycle
from categories LEFT OUTER JOIN judgment ON
(j_category=ca_code)
where j_case_no='45698'
and j_party_no=1
group by ca_code,ca_desc,ca_dis_cycle

Thanks,
Shaun
--------------------------------------------------------------------- 
Shaun, <mailto:swatts@computer-systems.com> 
Phone 1-317-913-4160 Fax 1-317-913-4175 
CSI - Computer Systems, Inc. <http://www.computer-systems.com/;
"Dictionary is the only place that success comes before work. Hard work is the price we 
must pay for success. I think you can accomplish anything if you're willing to pay the price."
Vince Lombardi 





view thread (2+ messages)  latest in thread

Message-ID: <6A1C87CA83BA8C419B1262B3728B12D102D435@csiserv1.computer-systems.com>
Permalink:  ../6A1C87CA83BA8C419B1262B3728B12D102D435@csiserv1.computer-systems.com/
Also on:    postgresql.org/message-id/6A1C87CA83BA8C419B1262B3728B12D102D435@csiserv1.computer-systems.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: SWatts@computer-systems.com
  Subject: Re: selecting problems
  In-Reply-To: <6A1C87CA83BA8C419B1262B3728B12D102D435@csiserv1.computer-systems.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