I created a simple sql query using rank function as shown below. My question is how do I check the values in the total_income to see if they are different?
Query:
select * from
(
select cardholderid, appcnum,total_income, Rank() over (PARTITION BY A.APPCNUM
ORDER BY A.EFFENDDATE DESC, A.EFFSTARTDATE DESC, A.CREATEDATE DESC) as Rank
from
TBL_EPIC_BILLSTATUS A
) tmp
where Rank in (2,3)
Results:
CARDHOLDER | APPCNUM | TOTAL_INCOME | RANK |
704355 | 2121362 | 21912 | 2 |
704355 | 2121362 | 20938 | 3 |