Home > database > For help! Two table check sum and reduction
For help! Two table check sum and reduction
Time:09-25
There are two tables, coating_out (table), coating_in (income), as shown in figure:
Two tables have a common field coatoutno, coatingout coatoutno is unique in the table, coatingin (income) in the table coatoutno have repeat, now need to coatingin (income) against coatoutno number in the table, put the coatinqty (income) the number of columns, reoccupy coatingout (a) in the table coatoutqty minus the coatinqty and (issue number), and the result on the balance (remainder) column, Write the SQL statement is as follows:
The results should be 10000, actual it is 60000, the figure below:
What a great god see mistakes in where? How to solve? Thank you very much!
CodePudding user response:
First GROUP, the SUM of two tables, respectively, and then the JOIN