Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> please help: outer join and group function
Hello,
I would appreciate any help on the following problem: I have two tables, for simplicity let's call them T1 and T2, of the following form:
T1:
c1 c2
T2:
s1 s2
I want to outer join these tables using
select t1.c2,t2.s2
from t1, t2
where t2.s1=t1.c1(+);
which gives:
C2 S2
--------- ---------
2 0 3 0 9
However, I additionally want, for each value of s2, only the row with the minimum value of c2 *AND* I need the result rows of the outer join where c2 is NULL:
C2 S2
--------- ---------
2 0 9
Applying "min(c2) ... group by s2" of course results in losing the rows where c2 is null. As to the complexity of the real joins (these are only demonstration tables), a UNION approach is useless.
Does anyone have a solution?
Thanks in advance,