tablename: lineitem
+----------------+-----+-----------+--------+
| item | amt | allocated | lotnum |
+----------------+-----+-----------+--------+
| bags galore | 20 | Received | 000590 |
| test inventory | 10 | Received | |
| bags galore | 19 | Shipped | 000590 |
| test inventory | 20 | Received | |
+----------------+-----+-----------+--------+
Hello, I’m trying to create a SQL formula, but I’ve hit a brick wall. Above is my table.
I’m looking for a formula that will compare the items and subtract where it is Shipped from Received on matching items and lotnum and it will add Received together.
So the end result is this.
+----------------+-----+--------+
| item | amt | lotnum |
+----------------+-----+--------+
| bags galore | 1 | 000590 |
+----------------+-----+--------+
| test inventory | 30 | |
+----------------+-----+--------+
Maybe something like this?