So I have a table that looks like this.

AvgCost   CompanyID         Policy#
25              22                    12
28              23                    12
35              24                    12
21              25                    12
20              22                    20
15              24                    20
13              23                    21
43              24                    21
I want it to rank the CompanyID's by average cost per each policy number. So the output would look like this:

AvgCost   CompanyID         Policy#         Rank
25              22                    12              2
28              23                    12              3
35              24                    12              4
21              25                    12              1
20              22                    20              2
15              24                    20              1
13              23                    21              1
43              24                    21              2
Anyone got an idea on how I could achieve this? Any help would be greatly appreciated.

Thank you.