Sử dụng ROW_NUMBER()
:
SELECT s.id,s.tag,s.version FROM (
SELECT t.*,
ROW_NUMBER() OVER(PARTITION BY t.id ORDER BY t.version DESC) as rnk
FROM YourTable t) s
WHERE s.rnk = 1
Sử dụng ROW_NUMBER()
:
SELECT s.id,s.tag,s.version FROM (
SELECT t.*,
ROW_NUMBER() OVER(PARTITION BY t.id ORDER BY t.version DESC) as rnk
FROM YourTable t) s
WHERE s.rnk = 1