| sib |
Posted: Jul 30, 2007 12:18:32 AM |
Total Post: 9
Joined: Nov, 2006
|
Hi,
A Table contains two columns, column1 and column2 respectively, where these columns represent some relationship which shows a > c , b > d, a >d, c >d. basically column1 > column2
column1 column2
a c
d b
a d
c d
I want the output to be greatest,next greatest, next next greatest like (n,n-1,n-2 etc) like
a -> c -> d - > b
It would be of great help if you could help in doing this.
Thanks in advance
Regards,
Sibghat
|
|
|
chinna |
| Posted: Jul 30, 2007 09:16:21 AM | |
|
Total Post: 28
Joined: May, 2007
|
hi sib,
Here is the required Explanation Of Query.
SQL> SELECT * FROM SIB;
NO1 NO2
---------- ----------
42 18
13 6
42 13
18 13
SQL> SELECT NO1 "A" FROM SIB
UNION
SELECT NO2 "A" FROM SIB
ORDER BY A DESC;
A
---------
42
18
13
6
I Hope this Query Gives Expected Results.
Plz Give Me Feedback.
Regards
Srawan
|
|
|
|
|
sib |
| Posted: Jul 30, 2007 11:53:04 PM | |
|
Total Post: 9
Joined: Nov, 2006
|
Thanks srawan,
Thank you very much/ Thank you so much for your timely help. Will it work for all combinations for example, if my column1 has abc and column2 has ab
like abc > ab etc..
I was thinking that we need to use some sort of analytical functions/ pivot queries.
Give me your thought.
Thanks for your time.
Regards
Sib
|
|
|
|
|
sib |
| Posted: Jul 30, 2007 11:56:40 PM | |
|
Total Post: 9
Joined: Nov, 2006
|
Hi srawan,
The query you provided will just sort and present, but the result set which i have described is not what i will get in your query.
Cheers
Sib
|
|
|
|
|
chinna |
| Posted: Jul 31, 2007 12:55:09 AM | |
|
Total Post: 28
Joined: May, 2007
|
Hi sib,
thanks for your feedback.
For any Values (ie abc>ab) it works ,i think no need of any anylitical functions.
but i don't got your point regarding resultset.
as my resultset gives descending oreder,is it not ur desired resultset.
do you want in a single row?
clarify me.
Thanks,
Srawan
|
|
|
|
|
sib |
| Posted: Jul 31, 2007 01:12:22 AM | |
|
Total Post: 9
Joined: Nov, 2006
|
Your output is just printing in asc/desc order, i want relationship
a > b
b > d
e > a
from the above relationship, it is clear that e is the biggest then comes b,d,a.
so e -> a -> b -> d
Regards,
Sib
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |