suman123
09-12-2003, 02:05 PM
I have this SQL :
---------------
select
e.emp_val1 as location,
e.emp_val3 as dept,
e.emp_val2 as clock,
e.emp_lastname || ', ' || e.emp_firstname as name,
ws1.wrks_udf1 as rate1,
ws2.wrks_udf1 as rate2,
ws3.wrks_udf1 as rate3,
ws4.wrks_udf1 as rate4,
ws5.wrks_udf1 as rate5,
ws5.wrks_udf1 as rate6,
( (
ws1.wrks_udf1 +
ws2.wrks_udf1 +
ws3.wrks_udf1 +
ws4.wrks_udf1 +
ws5.wrks_udf1 +
ws6.wrks_udf1
) /
(
decode (
(decode(ws1.wrks_udf1,'0',0,1) +
decode(ws2.wrks_udf1,'0',0,1) +
decode(ws3.wrks_udf1,'0',0,1) +
decode(ws4.wrks_udf1,'0',0,1) +
decode(ws5.wrks_udf1,'0',0,1) +
decode(ws6.wrks_udf1,'0',0,1)),'0',1, (decode(ws1.wrks_udf1,'0',0,1) +
decode(ws2.wrks_udf1,'0',0,1) +
decode(ws3.wrks_udf1,'0',0,1) +
decode(ws4.wrks_udf1,'0',0,1) +
decode(ws5.wrks_udf1,'0',0,1) +
decode(ws6.wrks_udf1,'0',0,1))
)
)
) as avgrate
from
employee e,
pay_group pg,
work_summary ws1,
work_summary ws2,
work_summary ws3,
work_summary ws4,
work_summary ws5,
work_summary ws6
where
e.emp_val1 = #request.dbLocation#
and e.emp_val1 = pg.paygrp_name
and ws1.emp_id = e.emp_id
and ws2.emp_id = e.emp_id
and ws3.emp_id = e.emp_id
and ws4.emp_id = e.emp_id
and ws5.emp_id = e.emp_id
and ws6.emp_id = e.emp_id
and pg.paygrp_end_date-42 = ws1.wrks_work_date
and pg.paygrp_end_date-35 = ws2.wrks_work_date
and pg.paygrp_end_date-28 = ws3.wrks_work_date
and pg.paygrp_end_date-21 = ws4.wrks_work_date
and pg.paygrp_end_date-14 = ws5.wrks_work_date
and pg.paygrp_end_date-7 = ws6.wrks_work_date
---------------
I want to do an outer join on the where clause like this :
where
e.emp_val1 = #request.dbLocation#
and e.emp_val1 = pg.paygrp_name
and ws1.emp_id = e.emp_id(+)
and ws2.emp_id = e.emp_id(+)
and ws3.emp_id = e.emp_id(+)
and ws4.emp_id = e.emp_id(+)
and ws5.emp_id = e.emp_id(+)
and ws6.emp_id = e.emp_id(+)
but Oracle complains that I cannot do an outer join from one table to more than one table. I dont want the outer join on the 'ws' side (left side). I want it on the right side as I have shown above.
Is there anyway to accomplish this ? Or maybe rewrite the query to accomplish it another way ?
Any help is greatly appreciated !
---------------
select
e.emp_val1 as location,
e.emp_val3 as dept,
e.emp_val2 as clock,
e.emp_lastname || ', ' || e.emp_firstname as name,
ws1.wrks_udf1 as rate1,
ws2.wrks_udf1 as rate2,
ws3.wrks_udf1 as rate3,
ws4.wrks_udf1 as rate4,
ws5.wrks_udf1 as rate5,
ws5.wrks_udf1 as rate6,
( (
ws1.wrks_udf1 +
ws2.wrks_udf1 +
ws3.wrks_udf1 +
ws4.wrks_udf1 +
ws5.wrks_udf1 +
ws6.wrks_udf1
) /
(
decode (
(decode(ws1.wrks_udf1,'0',0,1) +
decode(ws2.wrks_udf1,'0',0,1) +
decode(ws3.wrks_udf1,'0',0,1) +
decode(ws4.wrks_udf1,'0',0,1) +
decode(ws5.wrks_udf1,'0',0,1) +
decode(ws6.wrks_udf1,'0',0,1)),'0',1, (decode(ws1.wrks_udf1,'0',0,1) +
decode(ws2.wrks_udf1,'0',0,1) +
decode(ws3.wrks_udf1,'0',0,1) +
decode(ws4.wrks_udf1,'0',0,1) +
decode(ws5.wrks_udf1,'0',0,1) +
decode(ws6.wrks_udf1,'0',0,1))
)
)
) as avgrate
from
employee e,
pay_group pg,
work_summary ws1,
work_summary ws2,
work_summary ws3,
work_summary ws4,
work_summary ws5,
work_summary ws6
where
e.emp_val1 = #request.dbLocation#
and e.emp_val1 = pg.paygrp_name
and ws1.emp_id = e.emp_id
and ws2.emp_id = e.emp_id
and ws3.emp_id = e.emp_id
and ws4.emp_id = e.emp_id
and ws5.emp_id = e.emp_id
and ws6.emp_id = e.emp_id
and pg.paygrp_end_date-42 = ws1.wrks_work_date
and pg.paygrp_end_date-35 = ws2.wrks_work_date
and pg.paygrp_end_date-28 = ws3.wrks_work_date
and pg.paygrp_end_date-21 = ws4.wrks_work_date
and pg.paygrp_end_date-14 = ws5.wrks_work_date
and pg.paygrp_end_date-7 = ws6.wrks_work_date
---------------
I want to do an outer join on the where clause like this :
where
e.emp_val1 = #request.dbLocation#
and e.emp_val1 = pg.paygrp_name
and ws1.emp_id = e.emp_id(+)
and ws2.emp_id = e.emp_id(+)
and ws3.emp_id = e.emp_id(+)
and ws4.emp_id = e.emp_id(+)
and ws5.emp_id = e.emp_id(+)
and ws6.emp_id = e.emp_id(+)
but Oracle complains that I cannot do an outer join from one table to more than one table. I dont want the outer join on the 'ws' side (left side). I want it on the right side as I have shown above.
Is there anyway to accomplish this ? Or maybe rewrite the query to accomplish it another way ?
Any help is greatly appreciated !