How to merge two tables with computation MS Access?
我有2个表,几乎具有相同的属性。假设在表1中我具有这些属性。
1 2 | Item Quantity Unit Net Price Total Net Price asd 2 22 44 |
而且,在表2中:
1 2 | Item Quantity Unit Gross Price asd 1 20 |
您可以看到每个表的区别。
我需要将table2插入到table1并同时
1 | "INSERT INTO [table1] ([Item], [Quantity], [Unit Net Price], [Total Net Price]) SELECT * FROM [table2] WHERE [Unit Net Price] = [Unit Gross Price] * 1.10 AND [Total Net Price] = [Quantity] * [Total Net Price]" |
我正在使用
对于SQL解决方案,请使用此选项。
计算进入SELECT子句,而不是WHERE子句。
还请注意,您不能使用刚刚计算的字段([单位净价])来计算另一个字段([总净价]),所有计算都必须基于表2中的字段。
1 2 3 4 5 6 7 | INSERT INTO [table1] ([Item], [Quantity], [Unit Net Price], [Total Net Price]) SELECT [Item], [Quantity], [Unit Gross Price] * 1.10 AS [Unit Net Price], [Quantity] * [Unit Gross Price] * 1.10 AS [Total Net Price] FROM [table2] |