Kyougou
<Gold Donor>
- 1,639
- 5,300
I'm assuming that when you tried to filter by day you did something like:
select
a.nom_day_key,
a.employee_key,
a.local_start_dt,
a.local_end_dt,
a.mod_dt
from fact_aspect_emp_schedule_detail a
join
(
select
employee_key,
max(mod_dt) as max_mod_dt
from fact_aspect_emp_schedule_detail
group by
employee_key
) b
on a.employee_key = b.employee_key
and a.mod_dt = b.max_mod_dt
and nom_day_key = day_you_want
and thats why you didnt see all the results, I think if you add the clause to the inner query it works the way you want it to, like so:
select
a.nom_day_key,
a.employee_key,
a.local_start_dt,
a.local_end_dt,
a.mod_dt
from fact_aspect_emp_schedule_detail a
join
(
select
employee_key,
max(mod_dt) as max_mod_dt
from fact_aspect_emp_schedule_detail
where nom_day_key = day_you_want
group by
employee_key
) b
on a.employee_key = b.employee_key
and a.mod_dt = b.max_mod_dt
select
a.nom_day_key,
a.employee_key,
a.local_start_dt,
a.local_end_dt,
a.mod_dt
from fact_aspect_emp_schedule_detail a
join
(
select
employee_key,
max(mod_dt) as max_mod_dt
from fact_aspect_emp_schedule_detail
group by
employee_key
) b
on a.employee_key = b.employee_key
and a.mod_dt = b.max_mod_dt
and nom_day_key = day_you_want
and thats why you didnt see all the results, I think if you add the clause to the inner query it works the way you want it to, like so:
select
a.nom_day_key,
a.employee_key,
a.local_start_dt,
a.local_end_dt,
a.mod_dt
from fact_aspect_emp_schedule_detail a
join
(
select
employee_key,
max(mod_dt) as max_mod_dt
from fact_aspect_emp_schedule_detail
where nom_day_key = day_you_want
group by
employee_key
) b
on a.employee_key = b.employee_key
and a.mod_dt = b.max_mod_dt