Chức năng gió
WITH t AS (
SELECT *
,MAX(date) OVER(PARTITION BY id) max_date_by_id
FROM Item
)
SELECT *
FROM t
WHERE date = max_date_by_id
Áp dụng chéo
SELECT *
FROM Item t
CROSS APPLY (
SELECT MAX(date) max_date_by_id
FROM Item
WHERE id = t.id
)
WHERE date = max_date_by_id