select NAME,ADDR,ID,E_DT,P_DT,PD from C_VW ORDER BY PD DESC;
select NAME,ADDR, ID,E_DT,P_DT, MAX(PD) as LastRow
from C_VW
group by NAME, ADDR, ID, E_DT,P_DT
ORDER BY PD DESC;
select NAME,ADDR,ID,E_DT,P_DT,PD from
(
select NAME,ADDR,ID,E_DT,P_DT,PD,
row_number() over (partition by NAME order by PD desc) idx
from C_VW
where E_D= 'RT - M'
) a
where idx = 1
ORDER BY PD DESC;
it work, I also need to sort by the latest E_DT after sort by PD
select NAME,ADDR,ID,E_DT,P_DT,PD from
(
select NAME,ADDR,ID,E_DT,P_DT,PD,
row_number() over (partition by NAME order by PD desc, E_DT desc) idx
from C_VW
where E_D= 'RT - M'
) a
where idx = 1
ORDER BY PD DESC, E_DT desc;
Open in new window
or
Open in new window