I've a table with two columns, say, column1 and column2. Column2 is not unique. For each distinct value of column2, I want a random row, only one row, from the table?
i.e. my result set should have as many rows as the number of distinct values of column2.
eg:
column1 column2
x 1
y 2
z 1
I want the result to be
column1 column2
x 1
y 2
or
column1 column2
z 1
y 2
Is this possible using only SQL?