You can easily use a Window Functions such as ROW_NUMBER()
with partitioning option in order to group by Model
column to eliminate the duplicates, and then pick the first rows(rn=1
) returning from the subquery such as
WITH d AS
(
SELECT *, ROW_NUMBER() OVER (PARTITION BY Model) AS rn
FROM Devices
)
SELECT ID, Model -- , and the other columns
FROM d
WHERE rn = 1
Demo
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…