BS-7594, fix sql for pages