SQL Question - Retrieve latest records per initial
Posted on 2016-08-31
I have a table named HistoryChanges with following fields
ID (PK) Int Auto num
Initial varchar (5)
Other columns are not relevant
Would like to get all records from a given initial which were entered latest.
Meaning if Initial A entered first 5 records then Initial B entered another 5, later Initial A entered 2 records,
If I'm looking for Initial A I would only want see the last two records, while if searching for Initial B I would want see 5 records.
This could be determined either by ID which is auto num or by DateEntered which captures date and time record was entered.
PS, I have SQL Express 2005.