From: JIACHENG SUN on
table 1
ref code
1 code_1
1 code_2
2 code_3
2 code_5
........
........

table 2
code code_description value
code_1 description1 3.4
code_2 description2 3.5
code_3 description3 0
code_4 description4 0
code_5 description5 0

how to write a sql to get the result below:

ref code description value
1 code_1 description1 3.4
1 code_2 description2 3.5
1 code_3 description3 0
1 code_4 description4 0
1 code_5 description5 0
2 code_1 description1 3.4
2 code_2 description2 3.5
2 code_3 description3 0
2 code_4 description4 0
2 code_5 description5 0
............
.............

I tried to use outer join and nvl function, but still couldn't get the
result i need. Cos if we have 1000 refs in table 1, it is impossible
to use nvl. how do your guys think?

thanks so much!!
From: Michel Cadot on

"JIACHENG SUN" <sunjcb(a)googlemail.com> a �crit dans le message de news:
538246a1-9c3c-4c6f-aa3a-1bf7f2ea55d4(a)p24g2000yqm.googlegroups.com...
| table 1
| ref code
| 1 code_1
| 1 code_2
| 2 code_3
| 2 code_5
| .......
| .......
|
| table 2
| code code_description value
| code_1 description1 3.4
| code_2 description2 3.5
| code_3 description3 0
| code_4 description4 0
| code_5 description5 0
|
| how to write a sql to get the result below:
|
| ref code description value
| 1 code_1 description1 3.4
| 1 code_2 description2 3.5
| 1 code_3 description3 0
| 1 code_4 description4 0
| 1 code_5 description5 0
| 2 code_1 description1 3.4
| 2 code_2 description2 3.5
| 2 code_3 description3 0
| 2 code_4 description4 0
| 2 code_5 description5 0
| ...........
| ............
|
| I tried to use outer join and nvl function, but still couldn't get the
| result i need. Cos if we have 1000 refs in table 1, it is impossible
| to use nvl. how do your guys think?
|
| thanks so much!!

It is useless to repost the same question in other Oracle forums,
the same people answer to all of them.

So, once again:
Provide the statements for the simple example.
Explain with WORDS the rule to get the result.

Regards
Michel


From: Gerard H. Pille on
JIACHENG SUN wrote:
> table 1
> ref code
> 1 code_1
> 1 code_2
> 2 code_3
> 2 code_5
> .......
> .......
>
> table 2
> code code_description value
> code_1 description1 3.4
> code_2 description2 3.5
> code_3 description3 0
> code_4 description4 0
> code_5 description5 0
>
> how to write a sql to get the result below:
>
> ref code description value
> 1 code_1 description1 3.4
> 1 code_2 description2 3.5
> 1 code_3 description3 0
> 1 code_4 description4 0
> 1 code_5 description5 0
> 2 code_1 description1 3.4
> 2 code_2 description2 3.5
> 2 code_3 description3 0
> 2 code_4 description4 0
> 2 code_5 description5 0
> ...........
> ............
>
> I tried to use outer join and nvl function, but still couldn't get the
> result i need. Cos if we have 1000 refs in table 1, it is impossible
> to use nvl. how do your guys think?
>
> thanks so much!!

This looks like a simple full outer join to me. What "syntax" did you try? No NVL needed,
methinks.
From: Mark D Powell on
On Jan 25, 9:49 am, JIACHENG SUN <sun...(a)googlemail.com> wrote:
> table 1
> ref     code
> 1       code_1
> 1       code_2
> 2       code_3
> 2       code_5
> .......
> .......
>
> table 2
> code      code_description    value
> code_1    description1         3.4
> code_2    description2         3.5
> code_3    description3         0
> code_4    description4         0
> code_5    description5         0
>
> how to write a sql to get the result below:
>
> ref    code       description      value
> 1      code_1    description1       3.4
> 1      code_2    description2       3.5
> 1      code_3    description3       0
> 1      code_4    description4       0
> 1      code_5    description5       0
> 2      code_1    description1       3.4
> 2      code_2    description2       3.5
> 2      code_3    description3       0
> 2      code_4    description4       0
> 2      code_5    description5       0
> ...........
> ............
>
> I tried to use outer join and nvl function, but still couldn't get the
> result i need. Cos if we have 1000 refs in table 1,  it is impossible
> to use nvl. how do your guys think?
>
> thanks so much!!

Please do not cross-post. This thread is also posted to the server
forum where a potential answer has been posted.

From: JIACHENG SUN on
thanks so much for ALL your help.

It does help me a lot. I just finish all the script i need. :)

Sure, next time, i will post as much as info i could. Have a nice day!!