Col_1         Col_2
====================
A              
B              A
C              B
D              A
E              D
F              B

Result required in this way:

Col_1       Col_2
=================
A            B
A            D
B            C
B            F
D            E    
share|improve this question
This is not a forum to test the readability of obfuscated code. You need to explain the problem to a human. – Suresh Koya Sep 27 '12 at 4:43
so? show us what you've tried. At least show us the SQL that got you the first result. Have you tried order by col_1? Or perhaps order by col_1, col_2? – bdares Sep 27 '12 at 4:44
yeah I tried order by Col_1, Col_2. But, I didn't get suitable result. – user1702169 Sep 27 '12 at 4:59
Hi Suresh, I am not testing anybody with my obfuscated code. I am new to query language. – user1702169 Sep 27 '12 at 5:07
What about table structure, sample data? Is the first list actual table data in a single table? – Stefan Steinegger Sep 27 '12 at 11:13
feedback

closed as not a real question by bažmegakapa, ronalchn, HaskellElephant, John Conde, hochl Sep 27 '12 at 11:28

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

From all I know about your problem (that is what you write in the question), the following will produce the requested result:

SELECT 
  Col_2 as Col_1,
  Col_1 as Col_2
FROM table
WHERE Col_2 IS NOT NULL
ORDER BY Col_2, Col_1
share|improve this answer
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.