<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Compare 2 records in Same Table in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/compare-2-records-in-same-table/m-p/3827694#M778577</link>
    <description>How about this single SQL:&lt;BR /&gt;&lt;BR /&gt;select Acnt_key from table_A A&lt;BR /&gt;where not exists (&lt;BR /&gt;   select 1 from table_A B&lt;BR /&gt;    where B.ref_acnt_key = A.acnt_key&lt;BR /&gt;      and B.recrd_type = "N" )&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 21 Jul 2006 03:25:23 GMT</pubDate>
    <dc:creator>Steve Lewis</dc:creator>
    <dc:date>2006-07-21T03:25:23Z</dc:date>
    <item>
      <title>Compare 2 records in Same Table</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compare-2-records-in-same-table/m-p/3827690#M778573</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have the following data in table A.&lt;BR /&gt;Acnt key , recrd type , ref accnt key &lt;BR /&gt;1000 , F, Null &lt;BR /&gt;2000 , F, Null&lt;BR /&gt;3000,N, 2000&lt;BR /&gt;4000 C 1000&lt;BR /&gt;&lt;BR /&gt;i want to fetch records those Acnt key column not referred in &lt;BR /&gt;ref accnt key column of any other record whose type is 'N'. In above case i need to eliminate 2000,F,Null because 2000(accnt key) is referred in another record's 3000(accnt key) ref accnt key column whose record type is 'N'&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 20 Jul 2006 16:02:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compare-2-records-in-same-table/m-p/3827690#M778573</guid>
      <dc:creator>intp</dc:creator>
      <dc:date>2006-07-20T16:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 records in Same Table</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compare-2-records-in-same-table/m-p/3827691#M778574</link>
      <description>I've not tested this but just a &lt;BR /&gt;set operation should do the trick quickly.&lt;BR /&gt;If you work out the possible syntax errors, it should do the trick for you.&lt;BR /&gt;&lt;BR /&gt;select tba.Acntkey&lt;BR /&gt;from tbla tba&lt;BR /&gt;minus&lt;BR /&gt;(select tbb.refaccntky as Acntkey&lt;BR /&gt;from tbla tbb &lt;BR /&gt;where tbb.recrdtype = 'N');&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Jul 2006 17:01:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compare-2-records-in-same-table/m-p/3827691#M778574</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2006-07-20T17:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 records in Same Table</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compare-2-records-in-same-table/m-p/3827692#M778575</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;The Perl script below will accept piped input or will read a file of your data.  It is assumed that your fields are comma-delimited, like:&lt;BR /&gt;&lt;BR /&gt;1000,F,Null&lt;BR /&gt;2000,F,Null&lt;BR /&gt;3000,N,2000&lt;BR /&gt;4000,C,1000&lt;BR /&gt;&lt;BR /&gt;# cat ./filter&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my  %things;&lt;BR /&gt;my (@fld, @zot);&lt;BR /&gt;my  $key;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    @fld = split /,/, $_;&lt;BR /&gt;    $things{$fld[0]} =  $_;&lt;BR /&gt;    push  @zot, $fld[2] if $fld[1] =~/N/;&lt;BR /&gt;}&lt;BR /&gt;for $key (@zot) {&lt;BR /&gt;    delete $things{$key};&lt;BR /&gt;}&lt;BR /&gt;for $key (sort keys %things) {&lt;BR /&gt;    print "$things{$key}\n";&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...run as :&lt;BR /&gt;&lt;BR /&gt;# ./filter datafile&lt;BR /&gt;&lt;BR /&gt;(or):&lt;BR /&gt;&lt;BR /&gt;# echo "1000,F,Null\n2000,F,Null\n3000,N,2000\n4000,C,1000" | ./filter&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 20 Jul 2006 20:14:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compare-2-records-in-same-table/m-p/3827692#M778575</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-07-20T20:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 records in Same Table</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compare-2-records-in-same-table/m-p/3827693#M778576</link>
      <description>Jrf,  you know I like to suggest a perl solution for just about anything, but this problem seems to refers to a (relational) database table, asking for relational logic.&lt;BR /&gt;Just using sql would appear to be called for.&lt;BR /&gt;&lt;BR /&gt;Intp, Are you sure you have your 'nots' and 'eliminate' versus 'fetch' straight in the problem description?&lt;BR /&gt;&lt;BR /&gt;At any rate, it should be something along the lines of:&lt;BR /&gt;&lt;BR /&gt;select * from a a where exists (select 'x' from a b where b.ref_key = a.acnt_key and b.type = 'N');'&lt;BR /&gt;&lt;BR /&gt;Demo below.&lt;BR /&gt;Hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;create table A (acnt_key number(9), type char, ref_key number(9));&lt;BR /&gt;insert into a values (1000,'F',null);&lt;BR /&gt;:&lt;BR /&gt;:&lt;BR /&gt;insert into a values (4000,'C', 1000);&lt;BR /&gt;&lt;BR /&gt;select * from a order by acnt_key&lt;BR /&gt;&lt;BR /&gt;"ACNT_KEY","TYPE","REF_KEY"&lt;BR /&gt;"1000","F",""&lt;BR /&gt;"2000","F",""&lt;BR /&gt;"3000","N","2000"&lt;BR /&gt;"4000","C","1000"&lt;BR /&gt;&lt;BR /&gt;select * from a a &lt;BR /&gt;where exists (&lt;BR /&gt;  select 'x' &lt;BR /&gt;  from a b &lt;BR /&gt;  where a.acnt_key = b.ref_key &lt;BR /&gt;  and b.type = 'N');'&lt;BR /&gt;&lt;BR /&gt;ACNT_KEY TYPE REF_KEY &lt;BR /&gt;2000 F -  &lt;BR /&gt;</description>
      <pubDate>Thu, 20 Jul 2006 23:13:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compare-2-records-in-same-table/m-p/3827693#M778576</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-07-20T23:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 records in Same Table</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compare-2-records-in-same-table/m-p/3827694#M778577</link>
      <description>How about this single SQL:&lt;BR /&gt;&lt;BR /&gt;select Acnt_key from table_A A&lt;BR /&gt;where not exists (&lt;BR /&gt;   select 1 from table_A B&lt;BR /&gt;    where B.ref_acnt_key = A.acnt_key&lt;BR /&gt;      and B.recrd_type = "N" )&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 21 Jul 2006 03:25:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compare-2-records-in-same-table/m-p/3827694#M778577</guid>
      <dc:creator>Steve Lewis</dc:creator>
      <dc:date>2006-07-21T03:25:23Z</dc:date>
    </item>
  </channel>
</rss>

