Fixed SQLite top(limit) implementation