fix incorrect possition of LIMIT and OFFSET in SQL