I have look through the duplicated question but the solution there does not work for me.
I have two columns:
InstanceID
ProductID
and want to get the unique ProductIDs only.
From others questions asked here I try this solution:
SELECT *
FROM
(SELECT CAST(A.Col001 AS int) AS SurveyInstanceID ,
CAST(A.Col002 AS nvarchar(25)) AS ProductID ,
ROW_NUMBER() OVER(PARTITION BY A.Col002 ORDER BY A.Col001 DESC) rn
FROM DataSetsMaterializedDataSqlvariant A
WHERE DataSetsMaterializedInternalRowsetID = 5
) a
WHERE rn = 1
but I get as a result duplicated values.
EDIT:
For more information, this is what I have in my table:
InstanceID ProductID
1 10
1 11
1 12
1 13
2 10
2 A1
3 10
3 11
3 B1
3 C1
3 D1
3 E1
......
I need to get the unique Product IDs. I am sorry I did not provided example at the beg.