我正在编写一个查询来为员工提取转帐。这意味着在行之前的那行就是行为'转移'。一些员工在同一日期有转移行为和其他行为。但是,我的查询获取了Transfer日期为<的日期。我想写一些这样的事情: -Oracle SQL-如果在Where子句中写入案例
select *
from per_all_assignments_m paam
where paam.effective_start_date=
(case if (paam.effective_start_date=
(select max(paam1.effective_start_date)
from per_all_assignments_m paam1
where paam1.person_id=paam.person_id and
paam.assignment_id=paam1.assignment_id and
paam1.action_code <> 'TRANSFER' and
paa1.effective_latest_change='N')
)
then paam.effective_start_date
else (paam.effective_start_date=
(select max(paam1.effective_stat_date)
from per_all_assignments_m paam1
where paam.person_id=paam1.person_id and
paam.assignment_id=paam1.assignment_id and
paam1.effective_start_date <
(select max(paam2.effective_start_date)
from per_all_assignments_m paam2
where paam2.action_code='TRANSFER' and
paam1.person_id = paam2.person_id and
paam1.assignment_id=paam2.assignment_id)
)
)
)
Oracle中可能吗?
前年END)请格式化您的查询。提示:添加换行符并在每行的前面放置四个空格将其格式化为单色空间字体。 –