SQL for fixing faulty composer pages

DECLARE c CURSOR READ_ONLY FAST_FORWARD FOR
-- select MAX(pkID) as MaxID from tblWorkPage where fkPageID = 22493 group by fkLanguageBranchID
select MAX(b.pkID) from
(select MIN(a.fkPageID)as minid, MIN(a.fkLanguageBranchID) as minbranch from tblworkpage a
left join tblProperty b
on a.fkPageID = b.fkPageID
and a.fkLanguageBranchID = b.fkLanguageBranchID
and b.LongString like '%