Home > database >  Help: oracle implement multiple tables tied for according to the result set
Help: oracle implement multiple tables tied for according to the result set

Time:10-02

As shown in figure 1. The demand;

2. The figure appeared to be hanged:
Table 1: code, number 1, amount of 1
Table 2: encoding, number 2, amount 2
Table 3: encoding, number 3, amount 3
-- -- -- -- -- in the end I want the result: code number 1 2 number 3 1 number 2 amount payable 3
Have these fields according to the output, when three tables coding are equal, according to one line,
Example, the code in table 1 and table 2 and table 3 does not exist,
Are shown as follows: amount of code number 1 1 0 0 0 0



CodePudding user response:

give great god to a train of thought, I table 1 table 2 table 3 is now I'm through with a stored procedure as the table

CodePudding user response:

Write a stored procedure, or function call, using a cursor loop coding

CodePudding user response:

Consider the source of the multidimensional header, or under the direct control, the generated a table

CodePudding user response:

Just outside the correlation?
 with taba (" code ", "number 1", "1" amount) 
As
(
Select 1,11,111 from dual union all
Select 2,22,222 from dual union all
Select 3,33,333 from dual
), the firm (" code ", "number 2", "the amount of 2")
As
(
Select 1,11,111 from dual union all
Select 2,22,222 from dual
), tabc (" code ", "3", "amount")
As
(
Select 1,11,111 from dual
)
"Code", select a.
A. "number 1",
NVL (a. "1", 0),
NVL (b. "number 2", 0),
NVL (b. "2", 0),
NVL (c. "number 3, 0),
NVL (c. "3", 0)
The from taba a, the firm b, tabc c
Where a. "code"=b. "code" (+)
And a. "code"=c. "code" (+)

CodePudding user response:

 with taba (" code ", "number 1", "1" amount) 
As
(
Select 1,11,111 union all
Select 2,22,222 union all
Select 3,33,333
), the firm (" code ", "number 2", "the amount of 2")
As
(
Select 1,11,111 union all
Select 2,22,222
), tabc (" code ", "3", "amount")
As
(
Select 1,11,111
)

SELECT *
The FROM taba
LEFT the JOIN the firm ON the firm. Code=taba. Coding
LEFT the JOIN tabc ON tabc. Code=taba. Coding

CodePudding user response:

Yes, this is the common link ~
  • Related