Answers for "sql server select unique two columns"

SQL
0

sql 2 way of select unique

WITH CTE AS (
    SELECT  *
           ,row_number() OVER(PARTITION BY word, num ORDER BY id) AS row_num
    FROM    dupes
)
SELECT  word, num, id 
FROM    cte
WHERE   row_num = 1
ORDER BY word, num;

/*
word|num|id|
----|---|--|
aaa |100| 1|
bbb |200| 2|
bbb |400| 4|
ccc |300| 3|
ddd |400| 7|
*/
Posted by: Guest on August-15-2021

Code answers related to "sql server select unique two columns"

Code answers related to "SQL"

Browse Popular Code Answers by Language