SQL queries and files