Hello,
I have to update a table but using a subselect.
I'll first try to explain it in english.
I have an execution table which has as values executionID, symbol, volume, executionDate, orderID and side. I also have an order table which has an orderID, symbol, orderDate, side, matchStatus, and volume.
For each record in order there is one or more records in the execution table. Think of it this way. There is an order to BUY 100 shares of XYZ. The could be 2 executions for XYZ at 50 shares.
The execution.orderID and order.orderID is supposed to be the key that links each order with all the executions. The problem is that I have to create this relationship. I have all the information execept the orderID.
I need the DB to go through all the records that have a orders.matchStatus NULL and executions.orderID NULL and where the sum(volume) from the execution table equals the abs(volume) from the orders table - find the match and update.
The problem so far is that my subselect is returning too may records set.