Count occurrences by time

Good morning, I have a table that has the time a call was made, and the reference number associated with it. I would like to give each call an occurrence based on the reference number in time order.

For example

image

Desired output

image

I hope some can help.

Kind regards

David

SELECT CallDateTime, ID
,ROW_NUMBER() OVER (PARTITION BY ID ORDER BY CallDateTime) Occurance
FROM myTable
ORDER BY ID, CallDateTime
1 Like

Perfect thank you. I will have to learn the Row number over partition stuff.

Thanks for your help, much appreciated.