USING RANK

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


April 23rd, 2015 3:22pm

what do you mean by check values in total income?? you have column total column there right??

if i understand it right, you do another rank for total income..

Rank() over (partition by APPCnum order by total_income desc) as [total income

Free Windows Admin Tool Kit Click here and download it now
April 23rd, 2015 3:24pm

what do you mean by check values in total income?? you have column total column there right??

if i understand it right, you do another rank for total income..

Rank() over (partition by APPCnum order by total_income desc) as [total income

April 23rd, 2015 4:37pm

I agree with Stan210, if you want to see the difference of the total_income you should order by the rank on total income. This way if the total_income row is different but the appcnum is the same, there will be a count.

Regards,

Reshma

Free Windows Admin Tool Kit Click here and download it now
April 24th, 2015 2:21am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics