Hi there,
By way of intro I'm no expert but have managed to look at this and other forums to try to find a way to achieve what I need to (in Access 2007).
Essentially I'm trying to rank rows based on values (x) for each value of another field
. So the outcome will be an order ranking by x for each discrete value of y.
I have tried two methods to do this, but frankly they suck from a performance angle. They do both work and I have included them below.
My question is whether there are any suggestions that will speed things up to the point where they are usable. One thing to note is that in the code below the 'table' SubV12RFO is actually a query that draws from another 6 or so tables / queries. As I write this I'm thinking it may help to dump the output into a temporary table before running the queries below.
Anyway, any thoughts or suggestions appreciated.
ABOVE .... Works, but very slow!
ABOVE .... Also works, but very slow
Thanks,
Jacko
By way of intro I'm no expert but have managed to look at this and other forums to try to find a way to achieve what I need to (in Access 2007).
Essentially I'm trying to rank rows based on values (x) for each value of another field

I have tried two methods to do this, but frankly they suck from a performance angle. They do both work and I have included them below.
My question is whether there are any suggestions that will speed things up to the point where they are usable. One thing to note is that in the code below the 'table' SubV12RFO is actually a query that draws from another 6 or so tables / queries. As I write this I'm thinking it may help to dump the output into a temporary table before running the queries below.
Anyway, any thoughts or suggestions appreciated.
Code:
SELECT SubV12RFO.RID, SubV12RFO.FLD_TNO, SubV12RFO.MRID, IIf([RID]=[RID],(select count(*) from SubV12RFO AS D12RFO where
D12RFO.RID = SubV12RFO.RID and D12RFO.NPR > SubV12RFO.NPR)+1,"") AS FRank
FROM SubV12RFO
WHERE (((SubV12RFO.MID)=27857));
Code:
SELECT SubV12RFO.RID, SubV12RFO.FLD_TNO, SubV12RFO.MRID,
IIf(([RID]=[RID]),(SELECT COUNT([D12RFO].[NPR])
FROM SubV12RFO AS D12RFO
WHERE ([D12RFO].[NPR] > [SubV12RFO].[NPR]) And ([D12RFO].[RID]=[SubV12RFO].[RID])),"")+1 AS FRANK
FROM SubV12RFO
WHERE (((SubV12RFO.MID)=27857));
Thanks,
Jacko