There is no OFFSET support in AWS Athena, but we can use a workaround to get the same behavior.
Let’s assume that I want to execute this query:
SELECT * FROM some_table
ORDER BY column_A
OFFSET 20 LIMIT 10 -- this doesn't work
to get the desired outcome, I need three things:
- a window function that assigns a number to every row
- ordering method that sorts the table, so I get a deterministic outcome
- filtering function that selects only the rows I want
SELECT * FROM (
SELECT row_number() over(ORDER BY column_A) AS rn, * FROM some_table)
WHERE rn BETWEEN 20 AND 30; -- 30 = 20 (offset) + 10 (limit)
Get $80/Year of AI Expertise. For Free.
"I've learned a lot already from your blog."
— A Substack reader who has pledged $80 per year for this content.
I help SaaS startups with customer-facing LLMs stop AI hallucinations before they spark compliance nightmares or customer churn.
Why join?
- Straight-to-the-point articles on measuring and fixing hallucinations.
- Playbooks for advanced RAG tuning, guardrails, and evaluation you can copy-paste.
- Case studies from real deployments, not "Hello World" demos.
What to expect:
- 3-4 actionable emails per month.
- Proven expertise: 500+ articles & 1k+ engineers trained.
- Zero fluff, zero spam — just tactics that make your LLM stack safer.
Subscribe