My Query
Select ID, Date, Type, TypeID, Active from TableName
Results
ID      | Date                    | Type   | TypeID | Active 
------  | ----------------------- | ------ | ------ | ------
16026690| 2017-08-02 20:35:51.000 | Banana | 121    | 0
------  | ----------------------- | ------ | ------ | ------
16026695| 2017-08-02 20:43:03.000 | Banana | 121    | 0
------  | ----------------------- | ------ | ------ | ------
16026700| 2017-08-02 20:35:51.000 | Orange | 125    | 0
------  | ----------------------- | ------ | ------ | ------
16026705| 2017-08-02 20:43:03.000 | Orange | 125    | 0
------  | ----------------------- | ------ | ------ | ------
16026706| 2017-08-02 20:47:51.000 | Orange | 128    | 0
------  | ----------------------- | ------ | ------ | ------
16026706| 2017-08-02 20:50:51.000 | Orange | 128    | 0
------  | ----------------------- | ------ | ------ | ------
16026777| 2017-08-02 20:58:03.000 | Orange | 128    | 0
I want to return the most recent record for each Type/TypeID
So the results I want to see for the above table is:
ID      | Date                    | Type   | TypeID | Active 
------  | ----------------------- | ------ | ------ | ------
16026695| 2017-08-02 20:43:03.000 | Banana | 121    | 0
------  | ----------------------- | ------ | ------ | ------
16026705| 2017-08-02 20:43:03.000 | Orange | 125    | 0
------  | ----------------------- | ------ | ------ | ------
16026777| 2017-08-02 20:58:03.000 | Orange | 128    | 0
Can someone point me in the right direction to achieve this? I am using MS SQL 2016
 
     
     
    