Hello,
If I was using Oracle I would typically use a "ROW_NUMBER () OVER PARTITION BY" function, however it doesn't appear access supports that.
I created the below query which works great, except it doesn't partition by the empl_id field.
I get that is the function of "Top 1", but I really want the Top 1 for each unique empl_id ordered by the resp_date desc.
Can someone help me? I've been searching for a solution all morning.
If I was using Oracle I would typically use a "ROW_NUMBER () OVER PARTITION BY" function, however it doesn't appear access supports that.
I created the below query which works great, except it doesn't partition by the empl_id field.
I get that is the function of "Top 1", but I really want the Top 1 for each unique empl_id ordered by the resp_date desc.
Can someone help me? I've been searching for a solution all morning.
Code:
select u.* from(
select Top 1 v.* from (
select w.* from(
select Top 1 x.* from (
select y.* from (
select Top 1 z.* from(
select distinct e.empl_last_name & ', ' & e.empl_first_name & ' (' & ex.empl_id & ')' & ' - ' & j.title, e.empl_last_name,
e.empl_first_name,
ex.empl_id,
j.title,
jx.ref_id,
ex.resp_date as exresp,
ex.status as exstatus,
ax.resp_date as axresp,
ax.status as axstatus,
jx.status as jxstatus,
jx.resp_date as jxresp
from employee as e,
employee_ref as ex,
account as a,
account_ref as ax,
job_desc as j,
job_desc_ref as jx
where e.ref_id=ex.ref_id
and a.ref_id=ax.ref_id
and jx.ref_id=j.ref_id
and ax.empl_id=ex.empl_id
and jx.empl_id=ex.empl_id
and ((a.account_id)=left(right((forms!client_view.client_combo.value),5),3))
and jx.ref_id in (14,15)) z
order by z.exresp desc) y
where y.exstatus = 'A') x
order by x.axresp desc) w
where w.axstatus = 'A') v
order by v.jxresp desc) u
where u.jxstatus = 'A'
order by u.ref_id, u.empl_last_name asc;