Hi,
Try the following, adjusting your table name as needed:
SELECT A.[Policy Key], A.[Company Key], A.[Total Vehicle Premium],
DCount("*","tblRank","[Policy Key] = " & [A].[Policy Key] & " and [Total
Vehicle Premium] > " & [A].[Total Vehicle Premium])+1 AS Ranking
FROM tblRank AS A
ORDER BY DCount("*","tblRank","[Policy Key] = " & [A].[Policy Key] & " and
[Total Vehicle Premium] > " & [A].[Total Vehicle Premium])+1;
Note that it will rank those with an equal value as the same rank and
skip some ranks. So if you add another row with the values of 0, 6, 1376,
you wil get:
Policy Key Company Key Total Vehicle Premium Ranking
0 5 1801 1
0 4 1442 2
0 0 1441 3
0 6 1376 4
0 2 1376 4
0 1 1364 6
0 3 1331 7
Hope that helps,
Clifford Bass
DMosher said:
I am looking for SQL to rank the following data based on premium. Highest
premium = rank 1 and so on. Any ideas?
Policy Key Company Key Total Vehicle Premium
0 5 1801
0 4 1442
0 0 1441
0 2 1376
0 1 1364
0 3 1331
DMosher