CREATE VIEW `code_notebook_cell_latest` AS select "code_notebook_cell_id", "notebook_kernel_id", "notebook_name", "cell_name", "interpretable_code", "interpretable_code_hash", "description", "cell_governance", "arguments", "activity_log", COALESCE("updated_at", "created_at") as "version_timestamp" from "code_notebook_cell" where "code_notebook_cell"."code_notebook_cell_id" IN (
SELECT code_notebook_cell_id
FROM (
SELECT code_notebook_cell_id,
ROW_NUMBER() OVER (
PARTITION BY code_notebook_cell_id
ORDER BY COALESCE(updated_at, created_at) DESC
) AS rn
FROM code_notebook_cell
) ranked WHERE rn = 1
)