I'm trying to do something like:
select fred.name
, fred.emp_num
from fred
, joe
, (select * from
(select yr_bonus
, 1 grade
from mark
where mark.department = fred.department)
union
(select
0 yr_bonus
, 2 grade
from dual)
) pay
where fred.division = joe.division
and fred.grade = pay.grade;
This doesn't work. I can't seem to figure out how to tie mark.department to fred.department from 2 levels deep in selects. How do I accomplish this?