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 jyTable 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