update query - counting # records of id by time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a db with fields: id date/time. I am looking to create a count where
if it's the first date/time for an id, it states 1, then if second, 2 and so
on and so forth. I'm having trouble getting count to do this b/c of keeping
the date/time variable in there as a sorting variable - I just get 1. How
can I do this?
 
Try this ---
SELECT ID, UrDateTime, (SELECT COUNT(*)
FROM [alison77] T1
WHERE T1.ID = T.ID
AND T1.UrDateTime <= T.UrDateTime) AS Rank
FROM [alison77] AS T
ORDER BY ID, UrDateTime;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top