It doesn't return what I want exactly...
What it is giving me is the top 10 claims where the 3 important columns are:
Billed_Amt Total_Cost Vendor_Name
- giving me the descending amount of the costliest claims in $.
This is good; however, it is not giving me the SUM of total claims by vendor.
So for example, I am seeing that Hospital A is the vendor responsible for 5 out of the 10 claims on individual rows with a rank. So currently it holds 5 out of 10 slots on the list in terms of distinct claims.
Hospitals B, C, D, E each have 1 claim.
What I would like to see if the SUM of all the 5 claims by Hospital A, which ranks it #1.
Then the other hospitals will fall down in ranking and unless one of them has other cumulative claims, that hospital will just have one row in the report.
So like:
Billed_Amt Total_Cost_Pd Vendor_Name
1. $100,000 $55,000 Hospital A (comprised of 5 claims)
2. $ 99,000 $50,000 Hospital B (comprised of 1 claim)
....
Does that make sense?
I am incorrect in the SQL I posted because I am not getting distinct vendors using the 'SELECT DISTINCT TOP 10...' (they are repeating) and it seems that only the billed and cost amounts are what are distinct.
Many thanks!!!