Home > database >  SQL beg god for help
SQL beg god for help

Time:09-26

CodePudding user response:

Table B increase sequence, ID, or issue ID and time and again since the league their sum a same column. Then three tables is ok.

CodePudding user response:

So, what is the problem you want to check what kind of results to describe

CodePudding user response:

After writing your own table variables. Give you table variables too spend time...

DECLARE @ A TABLE
(Fno varchar (50),
Fname varchar (50),
Fqty int
);
DECLARE @ TABLE B
(sort int,
SO a varchar (50),
Fno varchar (50),
Fqty int
);



Insert into @ A (Fno, Fname, Fqty)
Select 'R06', ', 100 union all
Select 'our fleet', ', 200 union all
Select 'F10', ' ', 50 union all
Select 'A25', ', 300,


Insert into @ B (sort, SO, Fno Fqty)
Select 1, 'Ts05', 'R06, 100 union all
Select 2, 'Ts05', 'our fleet, 300 union all
Select 3, 'Tf08', 'R06, 200 union all
Select 4, 'Tc01', 'A25, 500



Select the sort, SO, Fno, Fqty=aFqty sumFqty - Fqty
The from (
The select b1. *, aFqty=a1. Fqty,
SumFqty=(select isnull (sum (Fqty), 0) from @ B where Fno=b1. Fno and sortThe from @ B b1 left join @ A a1
On a1. Fno=b1. Fno
) x

CodePudding user response:

The idea is that
In table B (acquisition table) project plan according to the first [projects] and [code] group sum up [plans to bring the number], and associated with A table (condition B table material code=A table material code)
B table sum - A number of inventory balance table is the result of the table C results you want
  • Related