Thanks worked like a charm.
Do you mind if I ask you another question?
How about if I want to to do an update statement on the returned recordset.
Something like
Code:
update executions
set orderID =
(
select o.orderid
from orders o, executions e, accounts a
where a.accountNumber = o.accountNumber and e.mcName = a.mcName
and o.matchStatus IS NULL and e.orderID IS NULL
and left(e.side, 1) = left(o.side, 1)
and o.orderDate = e.executionDate
and o.symbol = e.symbol
group by o.orderid, abs(o.volume)
having sum(e.volume) = abs(o.volume)
)
WHERE orderID IS NULL
Unfortunately my subselect returns multiple records.
What is the best way around this?