Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

choose only one for each distinct collumn regardless of other columns

WITH cte AS
(   SELECT *, ROW_NUMBER() OVER (PARTITION BY id ORDER BY val1 DESC) AS rn
    FROM MyTable
)
SELECT *
FROM cte
WHERE rn = 1
Source by www.codeproject.com #
 
PREVIOUS NEXT
Tagged: #choose #distinct #collumn #columns
ADD COMMENT
Topic
Name
9+6 =