Re: I can not add up columns when using a left outer join. Any ideas as to why?

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Robert Balzli Jr <robert(dot)balzli(at)xilinx(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: I can not add up columns when using a left outer join. Any ideas as to why?
Date: 2006-11-03 17:23:41
Message-ID: 121558.45416.qm@web31803.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I want to add x and y. John and Joe do not have a "y" value, so the LEFT
> JOIN returns NULL. Likewise Jane does not have a value for "x" so the
> LEFT JOIN returns null for her. The "x" and "y" columns are correct, but
> I would expect the "total" column to have 24, 232, and 4. myview is a
> view that converts id numbers to the actual names. run, project and name
> come from myview. Both x and y come from the site table.

> Can anyone tell me why the "total" column is empty?

becuase null + <pretty much anything> = null

check out COALESCE:
http://www.postgresql.org/docs/8.1/interactive/functions-conditional.html#AEN12654

Regards,

Richard Broersm Jr.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2006-11-03 17:24:09 Re: fetching unique pins in a high-transaction
Previous Message Martijn van Oosterhout 2006-11-03 17:22:12 Re: explosion of tiny tables representing multiple fields--Is this necessary?