Hi, I’m trying a query to perform an update from a sub-query, but it gives me an error.
The query is as follows:
WITH up AS (select index_time, ColA, ColB from MyTabTmp)
UPDATE MyTab mt
SET mt.ColA = up.ColA, mt.ColB = up.ColB
FROM up WHERE mt.index_time=up.index_time;
‘=’ expected
I get the same error with your query, see example at the link:
WITH up AS (
SELECT p.ask - p.bid AS spread, s.timestamp
FROM prices p
JOIN instruments i ON p.symbol = i.symbol
WHERE i.type = ‘BOND’
)
UPDATE spreads s
SET s.spread = up.spread
FROM up
WHERE s.timestamp = up.timestamp;