Пожалуйста, попробуйте с кодом ниже
DECLARE @DeliveryCarInfo TABLE (id int,modelId int,locationId int null,DateCreated date)
INSERT INTO @DeliveryCarInfo
(
id,
modelId,
locationId,
DateCreated
)
VALUES
(1 ,1 ,5,'02/03/2019'),
(2 ,2 ,null,'01/14/2019'),
(3 ,2 ,0,'02/03/2019'),
(4 ,2 ,5,'12/30/2018'),
(5 ,4 ,3,'01/10/2019'),
(6 ,3 ,5,'02/14/2019'),
(7 ,2 ,5,'03/13/2019')
Select X.Id,X.modelId,X.locationId,X.DateCreated from (SELECT *,row_number() OVER (PARTITION by modelId,locationId ORDER BY dateCreated desc)R FROM @DeliveryCarInfo
)X
WHERE X.R=1
ORDER BY X.modelId,X.DateCreated