- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Corelated Subquery ?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2007 03:27 AM
тАО02-20-2007 03:27 AM
Corelated Subquery ?
I need to find particular column value(ColActual) and
get its replacement item (colReplace) AND
if ColReplace is available as ColActual
then i need to find the colReplace for that record and display it.
For Example
Sample data
ColActual ----- ColReplace
Item1---------- Item4
Item4---------- Item10
My output should be "Item 10" based on above sample data , because
1) First i will find Item 1 and find its replace which is Item4.
2) Then i'll check for Item4 in "ColActual" which is present , so then i will have to
get its ColReplace value which Item 10.
Problem.....
i have situations like following...check Item1 referring back to itself.
ColActual ----- ColReplace
Item2---------- Item6
Item3---------- Item10
Item1---------- Item4
Item6---------- Item9
Item11---------- Item14
Item4---------- Item1
My requirement now is to identify ONLY such recurrsive data.I need
both records in my output (if possible in ordered fashion).
For example , for the given data the output should be ,
ColActual ----- ColReplace
Item1---------- Item4
Item4---------- Item1
Is this possible in one query. I cant write a procedure for this as i dont have access to create procedures.
PLS HELP .. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2007 04:35 AM
тАО02-20-2007 04:35 AM
Re: Corelated Subquery ?
Oracle?
Flat-files?
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2007 04:51 AM
тАО02-20-2007 04:51 AM
Re: Corelated Subquery ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2007 05:37 AM
тАО02-20-2007 05:37 AM
Re: Corelated Subquery ?
~cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2007 05:42 AM
тАО02-20-2007 05:42 AM
Re: Corelated Subquery ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2007 05:59 AM
тАО02-20-2007 05:59 AM
Re: Corelated Subquery ?
select * from your_table yt,
(select ColActual from your_table) t1
where t1.ColActual = yt.ColReplace
/
~hope it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2007 03:09 PM
тАО02-20-2007 03:09 PM
Re: Corelated Subquery ?
Chapter 11, "Advanced Searching: Determining Which Rows Are Reciprocals"
http://www.oreilly.com/catalog/sqlckbk/
SQL> drop table test;
Table dropped.
SQL> create table test (ColActual varchar(10), ColReplace varchar(10));
Table created.
SQL> set feedback off
SQL> insert into test values ( 'Item2', 'Item6');
SQL> insert into test values ( 'Item3', 'Item10');
SQL> insert into test values ( 'Item1', 'Item4');
SQL> insert into test values ( 'Item6', 'Item9');
SQL> insert into test values ( 'Item11', 'Item14');
SQL> insert into test values ( 'Item4', 'Item1');
SQL> select * from test;
COLACTUAL COLREPLACE
---------- ----------
Item2 Item6
Item3 Item10
Item1 Item4
Item6 Item9
Item11 Item14
Item4 Item1
SQL> select distinct v1.* from test v1, test v2
2 where v1.ColActual = v2.ColReplace
3 and v2.ColActual = v1.ColReplace
4
SQL> /
COLACTUAL COLREPLACE
---------- ----------
Item4 Item1
Item1 Item4
SQL>
note, this does NOT catch loops with more than 1 hop!
Cheers,
Hein.