Fix SQL query signatures