Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Query help needed

Re: SQL Query help needed

From: tina london <tinalondon_at_demon.co.uk>
Date: Fri, 24 Jun 2005 15:22:37 +0100
Message-ID: <d9h4vo$mab$1$8302bc10@news.demon.co.uk>

<surenm_at_gmail.com> wrote in message
news:1119621660.751261.222420_at_z14g2000cwz.googlegroups.com...
> I have the following two tables (AA & BB) that I need to use to
> populate a third table (CC)
>
> Table AA
> item_code type rel_code
> 1_01 1
> 1_02 1
> 1_03 1
> 1_04 1
> 1_05 1
> 1_06 1
> 2_01 2 abc
> 2_02 2 bcd
> 2_03 2 cde
>
> Table BB
> rel_code item_code
> abc 1_01
> abc 1_02
> abc 1_04
> abc 1_06
> bcd 1_02
> bcd 1_05
> bcd 1_06
> cde 1_02
> cde 1_04
>
> >From these tables, I need to populate the third table
> Table CC
> item_code_1 item_code_2 priority
> 1_01 2_01 1
>
> 1_02 2_01 1
> 1_02 2_02 2
> 1_02 2_03 3
>
> 1_04 2_01 1
> 1_04 2_03 2
>
> 1_05 2_02 1
>
> 1_06 2_01 1
> 1_06 2_02 2
>
> Note that the priority field in table CC is a counter
>
> I got the select working that gives me item_code_1 and item_code_2 but
> I don't know how to set the
> priority field (counter) in the SQL.
>
> Any help will be appreciated.
>

making the fatal assumption that this is not homework, you could try the following.

select item_code_1,

        item_code_2,
        priority

from aa a, bb b
where a.rel_code = b.rel_code

thus completeing the two table join

NOTE not tested Received on Fri Jun 24 2005 - 09:22:37 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US