Home > database >  SQL table data into two new tables (inbound, outbound, inventory)
SQL table data into two new tables (inbound, outbound, inventory)

Time:11-14

'empty library statistics (RKTJ), outbound (CKTJ) statistics, statistics (tj) three data in the table
SQL="DELETE * From RKTJ WHERE 1=1"

SQL="DELETE * From CKTJ WHERE 1=1"

SQL="DELETE * From tj WHERE 1=1"

'insert data into three tables
"INSERT INTO RKTJ (PM, xh, LSJ, RKSL) SELECT rk PM, rk xh, rk LSJ, Sum (rk RKSL) AS inbound From fairly rk GROUP BY rk PM, rk xh, rk LSJ HAVING Sum (rk) [RKSL]"

"INSERT INTO CKTJ (PM, xh, LSJ, CKSL) SELECT PM, xh, LSJ, Sum (CKSL) AS outbound From ck GROUP BY PM, xh, LSJ HAVING (((Sum (ck. [CKSL])) & lt;> False));"
"INSERT INTO tj (PM, xh, LSJ, RKSL CKSL, jy) SELECT RKTJ. PM, RKTJ. Xh, RKTJ. LSJ, RKTJ. RKSL AS warehousing, CKTJ. CKSL AS outbound, RKTJ. RKSL - CKTJ. CKSL balance AS the From RKTJ, CKTJ WHERE RKTJ. PM=CKTJ. PM;"

SQL="select * from tj"

So it is concluded that as a result of the inventory is not complete, only been library are displayed, and how to make him without library is shown in it at the same time?

CodePudding user response:

 
- it is ok to use left join
INSERT INTO tj (PM, xh, LSJ, RKSL, CKSL, jy)
The SELECT RKTJ. PM, RKTJ xh, RKTJ. LSJ, RKTJ. RKSL AS warehousing, CKTJ. CKSL AS outbound, RKTJ. RKSL - CKTJ. Balance CKSL AS
The FROM RKTJ LEFT join CKTJ on RKTJ. PM=CKTJ. PM;

CodePudding user response:

Field: the PM name xh model LSJ retail RKSL inventory quantity CKSL outbound quantity balance jy
Table structure:
Warehousing fields in the table PM xh LSJ RKSL
Outbound table PM xh LSJ CKSL
Required results:
Statistical results in the insert TAB PM xh LSJ RKSL CKSL jy

CodePudding user response:

The
reference 1/f, sleet response:
 
- it is ok to use left join
INSERT INTO tj (PM, xh, LSJ, RKSL, CKSL, jy)
The SELECT RKTJ. PM, RKTJ xh, RKTJ. LSJ, RKTJ. RKSL AS warehousing, CKTJ. CKSL AS outbound, RKTJ. RKSL - CKTJ. Balance CKSL AS
The FROM RKTJ LEFT join CKTJ on RKTJ. PM=CKTJ. PM;

Bosses, this not line, to perform the required input RKSL and CKSL... Not be completed

CodePudding user response:

From SQL server's point of view, completely no problem, you this request input RKSL and CKSL, it did not know, what's your database

CodePudding user response:

access

CodePudding user response:

reference 5 floor llSnakesss reply:
access

Access the grammar is also no problem ah, how would want input storage quantity and the delivery