Let us see a requirement :
we need show the Max(ID) of each loan record however each loan has one more records.
How will we do?
The best and the first way is :
Let me show you by Row_Number() Over(partition by colnum1 order by colnum2) as No to make it effective.
;with cte as
(
select Row_number() over (partition by servicerloannumber order by hmpmodificationdataid desc) as no, * from hmpmodificationdata
where servicerloannumber in