Q:

Distinct on each column

I need to select 3 columns from a table, but I need each value from any column to be unique in the resultset for this column.
This query:
SELECT DISTINCT TOP 10 a, b, c
FROM   x

will return 10 distinct sets.
How do I do it? 

A:

WITH q AS
        (
        SELECT  a, b, с, ROW_NUMBER() OVER (ORDER BY a, b, c) AS rn
        FROM    mytable
        )
SELECT  TOP 10 a, b, c
FROM    q q1
WHERE   NOT EXISTS
        (
        SELECT  1
        FROM    q
        WHERE   q.rn < q1.rn
                AND q.a = q1.a
        )
        AND NOT EXISTS
        (
        SELECT  1
        FROM    q
        WHERE   q.rn < q1.rn
                AND q.b = q1.b
        )
        AND NOT EXISTS
        (
        SELECT  1
        FROM    q
        WHERE   q.rn < q1.rn
                AND q.c = q1.c
        )

