我正在編寫一個查詢來爲員工提取轉帳。這意味着在行之前的那行就是行爲'轉移'。一些員工在同一日期有轉移行爲和其他行爲。但是,我的查詢獲取了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)請格式化您的查詢。提示:添加換行符並在每行的前面放置四個空格將其格式化爲單色空間字體。 –