Re: Outer Join and Group By
From: Ian Bainbridge <bainbridge_i_at_perc03_at_bgers.co.uk>
Date: 1995/08/03
Message-ID: <3vq73i$j8_at_atlas.bgers.co.uk>#1/1
Date: 1995/08/03
Message-ID: <3vq73i$j8_at_atlas.bgers.co.uk>#1/1
Simon,
All that you described seems very reasonable to me and gives the results I would expect.
Your example
select IN_NUMBER, IN_NAME, sum(OUT_AMOUNT) from INNER, OUTER where IN_NUMBER = OUT_NUMBER (+) and OUT_MONTH >= '9504' group by IN_NUMBER, IN_NAME;
will never produce what you require because the outer join for
2 XYZ Corp
will have a NULL OUT_MONTH which will fail your test of >= '9504'
You could change this to
and (OUT_MONTH >= '9504' or OUT_MONTH is null)
I think this will produce what your require (NB Untested !)
I suggest you might also want to consider wrapping a NVL around sum(OUT_AMOUNT) unless you actually want to distinguish between zero and null. Hust my thoughts - treat them as you will.
-- +--------------------------+-------------------------+-----------------------+Received on Thu Aug 03 1995 - 00:00:00 CEST
| Ian Bainbridge | bainbridge.i_at_bgers.co.uk|Phone: (44)191-216-0202|
| British Gas ERS | Newcastle Upon Tyne, UK | x2790 |
+--------------------------+-------------------------+-----------------------+