Home » SQL & PL/SQL » SQL & PL/SQL » is this possible?
is this possible? [message #323629] Thu, 29 May 2008 01:25 Go to next message
LaxmiRam
Messages: 2
Registered: May 2008
Junior Member
frndz...

out of interest.. i got this question in mind!

consider this table....

A B
2 4
3 5
4 6
5 8
6 10

if i give the value for 2 in col A i need to get output as
A B
2 4
4 6
6 10


i corresponding value in col B for the give values of col A should be retrieved and if that value is present in Col A then that corresponding value.

is this possible...?

do teach me!
Lakshmi
Re: is this possible? [message #323633 is a reply to message #323629] Thu, 29 May 2008 01:39 Go to previous messageGo to next message
Michel Cadot
Messages: 64102
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yes, it is possible.
Have a look at hierarchical query

If you want more precise answer, post a test case: create table and insert statements. Also post the result you want with these data.

Don't forget to read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel

Re: is this possible? [message #323714 is a reply to message #323633] Thu, 29 May 2008 05:34 Go to previous messageGo to next message
mkumaran85
Messages: 1
Registered: May 2008
Junior Member

SELECT *
FROM test;
end;

A B

2 4
3 5
4 6
5 8
6 10


SELECT a,b
FROM test
START WITH a=:a
CONNECT BY PRIOR b=a;

if (:a=2)

OUTPUT:
A B

2 4
4 6
6 10

if(:a=3)

A B

3 5
5 8

Hope this code is clear


Thanks
Muthu.



Re: is this possible? [message #323725 is a reply to message #323714] Thu, 29 May 2008 05:54 Go to previous message
Michel Cadot
Messages: 64102
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Thanks for cooperating in this forum.
The links and remarks I posted are for everyone including you.

Note it is far better to copy and paste a real SQL*Plus session.

Regards
Michel

[Updated on: Thu, 29 May 2008 05:55]

Report message to a moderator

Previous Topic: distinct case statement
Next Topic: To do in a single query
Goto Forum:
  


Current Time: Fri Dec 02 22:47:36 CST 2016

Total time taken to generate the page: 0.10029 seconds