tablename: lineitem
+----------------+-----+-----------+--------+
| item | amt | allocated | lotnum |
+----------------+-----+-----------+--------+
| bags galore | 20 | Received | 000590 |
| test inventory | 10 | Received | |
| bags galore | 19 | Shipped | 000590 |
| test inventory | 20 | Received | |
+----------------+-----+-----------+--------+
你好,我正在尝试创建一个 SQL 公式,但我碰壁了。上面是我的桌子。
我正在寻找一个公式,该公式将比较项目并从匹配项目和 lotnum 的 Received 中减去它的发货位置,并将 Received 加在一起。
所以最终的结果是这样的。
+----------------+-----+--------+
| item | amt | lotnum |
+----------------+-----+--------+
| bags galore | 1 | 000590 |
+----------------+-----+--------+
| test inventory | 30 | |
+----------------+-----+--------+