Dear Victoria:
I've edited your query a bit, below:
SELECT PATIENT_ID, ND_ID,
(SELECT COUNT(*) + 1 FROM tbl7 T1
WHERE T1.PATIENT_ID = tbl7.PATIENT_ID
AND T1.ND_ID < tbl7.ND_ID) AS Rank
FROM tbl7;
Certain features of what I proposed, specifically the aliasing of the table,
seem to have disappeared in your version. I have also dropped the INTO
clause, which you can reinsert when you're ready, as I feel this makes it
easier for you to see what is happening.
Does this help?
Tom Ellison
Victoria said:
I converted that to what is below for my purposes and everything came back
as
having a rank of 1. Any suggestions?
SELECT [tbl7].[PATIENT_ID], [tbl7].[ND_ID], (SELECT COUNT(*) + 1 FROM tbl7
WHERE tbl7.PATIENT_ID = tbl7.PATIENT_ID AND tbl7.ND_ID <
tbl7.ND_ID) AS Rank INTO tbl8
FROM tbl7;
Tom Ellison said:
Dear Victoria:
Using my own names for your table and columns:
SELECT Name, SequenceNumber,
(SELECT COUNT(*) + 1 FROM YourTable T1
WHERE T1.Name = T.Name
AND T1.SequenceNumber < T.SequenceNumber) AS Rank
FROM YourTable T
This assumes that the Name and SequenceNumber columns you have are, when
taken together, unique. Otherwise, the Rank column may repeat, as it
cannot
distinguish between itentical rows. An additional column could be used
to
break ties if you wish.
Tom Ellison
I need to figure out a way in access to give sequential numbers to
different
records based on another number (increasing in order) for each person.
For
example, Jane Doe has 5 records and I need those to be numbered 1-5
based
on
the numbers (or IDs) 97014, 97015, 97016, 97017, 97018. So I need to
create
the sequential numbers at a "person" level. Does anyone have a simple
way
to
do this?
Thanks so much!!!