Distinct multiple columns
632909Oct 2 2008 — edited Oct 2 2008Hi Guys,
I am trying to run a distinct query on a multiple columns, but not getting the required result. Here's my query:
SELECT distinct a.col1,
a.col2,
a.col3,
b.col4,
b.col5,
b.col6
FROM table1 a, table2 b
WHERE a.col2 = b.col2
AND a.col1 = 111;
Here's the result I am getting:
col1 col2 col2 col4 col5 col6
111 1 2 3 4 5
111 6 7 3 4 5
Distinct worked as two rows are distinct. But, I only want either of the above two rows, so my result should be as given below. I don't want any duplicate value in my other rows. Each row needs to have distinct values in each field. So, it should be something like this:
111 1 2 3 4 5
111 6 7 8 9 10
I tried to use 'rownum' but it didn't work either.
Any help is appreciated.
Thanks in advance.
Edited by: One&Only on Oct 2, 2008 9:46 AM