Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> Query Help

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: Query Help
 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

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Vinoth Kumar357
  Gopu Gopi340
  Gitesh Trivedi322
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software