Question

I have a ranking table, containing scores on different ranks:

(R)  Rankname:  string, name of the rank
(ID) PlayerID:  foreign key(int)
(S)  Score:     integer, higher score means higher endrank
(P)  Position:  integer, representing the location in the rank

Prior to update:

 R    ID   S    P
'a'   0    5   "undefined"
'a'   1   10   "undefined"
'a'   2   15   "undefined"
'b'   0    5   "undefined"
'b'   1   10   "undefined"
'b'   2   10   "undefined"
'b'   3   15   "undefined"

After update:

'a'   0    5    3
'a'   1   10    2
'a'   2   15    1
'b'   0    5    3
'b'   1   10    2
'b'   2   10    2
'b'   3   15    1

I tried to make a query that uses UPDATE as well as DENSE_RANK but I couldn't figure out how to make it work.

No correct solution

OTHER TIPS

This is dependent on creating a query to count distinct records, in the example, this query is called qry. To update your table, you can then say:

UPDATE MyTable 
SET MyTable.P = 
  DCount("*","qry","s<=" & [MyTable].[s] & " and r=""" & [MyTable].[r] & """");

There is one more point to note, this is qry:

SELECT DISTINCT z.r, z.s
FROM MyTable AS z;

MyTable is aliased.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top