I have a table with two columns, Column a is required to be displayed on the order of Column b. Since there is multiple occurance of Col a, I want to show a distinct list of Column a on the order of Column b.
I did the follwing query.
select distinct a.column_a from
( select column_a, column_b
table t order by column_b) a
The distinct values are not showing in the order of Column b. I understand the reason for this also. But is there any other way out ?
I'm not sure I understood what you really want; a simple test case would help. However, I have created it myself. You never mentioned what happens with 'column_b' - does it have distinct values, for example?
OK, here it is: first, a table and several records:
SQL> select * from test
As I've understood your question, this is the situation; in the case that the same 'col_a' has several 'col_b' values, I'll take the "first" one (minimum):
In order to produce such an output, you could use such a query:
SQL> select distinct t1.cola
2 from test t1
3 order by (select min(t2.colb) from test t2
4 where t2.cola = t1.cola
As I've already said, I'm not sure whether this is what you want. If not, provide a sample CREATE TABLE and INSERT INTO statements with the desired output, so that we could see (and, actually, try to code) what you need.