| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: desperately need ur help!
Hi Henry !
If you don't want to use outer join, you might utilize in-line function
instead.
For ex.: you query might look like this:
select
dept.number,
(select nvl(sum(emp.salary),0) from emp where emp.number in
(select employee from emp_dept where dept = dept.number)
) sum_salary
from dept
This query will return zero if there are no employees in particular department.
Frankly, you can use outer join nonetheless, in this case your query will be:
select
dept.number
,nvl(sum(emp.salary),0) sum_salary
from
dept t1 ,emp_dept t2 ,emp t3
t1.dept(+) = t2.number and
t3.number(+) = t2.employee
In some cases, this query will work a bit slower.
Regards !
Valery.
"Henry" <hxzhang_at_binary-solutions.net> wrote in message
news:EK2o8.2397$8f5.37440_at_news0.telusplanet.net...
> Forgive me for posting it here, but I really can't get any answer
elsewhere.
> :-(
>
> I have two entities: EMP and DEPT, for employee and department
respectively,
>
>
>
>
> >
>
> > > > > > > >Received on Tue Mar 26 2002 - 12:40:35 CST
![]() |
![]() |