Q:

How can I add a unique identifier for each "account ID" in my database table?

I am generating a temp table with duplicate entries for each "account ID". And I want all records with the same account ID to have an identifier. For example, all records with account ID: 1234 should have an identifier of 1. All records with account ID: 4321 should have an identifier of 2. 
I have added a column to my temp table for this field, but I do not know how to populate it based off the account IDs. 

A:

You don't need an additional identifier, just group by your account number and select the max(date) for each, like:
Select accountID, max(lastUpdated)
from t
group by accountID

