rewritten sql queries to sqlite standard... passing query test successful