fix sql for fixtures and query