i want to get a last row based of Updated_ts on the bases of same gr_number and course
i am using below query.
select t.*
from (select st.gr_number,st.course,st.is_active_flg,st.status,st.updated_ts
,sum(case when st.status = 'COMPLETED' then 1 else 0 end) over (partition by st.gr_number) as completedCourse,
sum(case when st.status <> 'COMPLETED' and st.status <> 'APPLICATION' and st.is_active_flg = 'N' then 1 else 0 end) over (partition by st.gr_number) as IncompletCourse
from admission_log st
join course cr on cr.course_id=st.course
order by st.gr_number,st.course,st.updated_ts
) t
where completedCourse > 0 and IncompletCourse > 0;
this query gives me result as
from above result i want only last value against the same gr_number and course based of Updated_ts
like
please help