Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Order of execution in a single SQL
UPDATE work_items set execution_order = (
SELECT
(
(
SELECT execution_order
FROM work_items
WHERE id = '12262'
)
+
(
SELECT execution_order
FROM work_items
WHERE execution_order < (
SELECT execution_order
FROM work_items
WHERE id = '12938'
)
ORDER BY execution_order DESC
LIMIT 1
)
)
/2
)
WHERE id = 12938;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment