Hi nabilabolo,
Use below query and call in your code.
SQL
CREATE TABLE #Test (Date DATE,Data CHAR(1))
INSERT INTO #Test VALUES('2021-01-26','A')
INSERT INTO #Test VALUES('2021-01-01','A')
INSERT INTO #Test VALUES('2020-12-21','B')
;WITH cte AS
(
SELECT *,
ROW_NUMBER() OVER (PARTITION BY Data ORDER BY Date DESC) AS rn
FROM #Test
)
SELECT Date,Data
FROM cte
WHERE rn = 1
DROP TABLE #Test
Output
Date Data
2021-01-26 A
2020-12-21 B