Fix SQLite accounting queries