OODB Update with Aggregate Function

270 Views Asked by At

I'm trying to update a column in my table "InventoryTable" with the SUM of values returned from Querying my other table "OrderTable"

I found several other questions like this here, and composed this statement:

UPDATE InventoryTable
SET SalesPerMonth = foo.ASPM
FROM InventoryTable
INNER JOIN (
    SELECT InventoryID, SUM(Quantity) AS ASPM
    FROM OrderTable
    GROUP BY InventoryID
) AS foo ON foo.InventoryID = InventoryTable.InventoryID 

I'm using this on OpenOffice Base SQL Edit and I keep getting a syntax error:

Syntax Error in SQL Expression

with these details:

SQL Status: HY000 Error code: 1000
syntax error, unexpected $end, expecting BETWEEN or IN or SQL_TOKEN_LIKE

I cannot figure out what I am doing wrong.

Thank you.

0

There are 0 best solutions below