Reputation: 1466
I've a query which returns the following data
as you can see in the image the colored groups are similar regarding column "A" i want to take the first occurrence of these rows regarding column "A" and discard the rest.
so i can end up with this result.
any solutions?
Thanks :)
Update:
this is the original query results
Upvotes: 5
Views: 159
Reputation: 24134
I would do it as follows:
WITH T(A, B, C, D, RowNum) AS
(
SELECT A, B, C, D, ROW_NUMBER() OVER (PARTITION BY A ORDER BY A)
FROM MyTable
)
SELECT * FROM T
WHERE
RowNum = 1
Upvotes: 6