SQL
All Top 50 SQL Interview Questions#7
Implement API Pagination with LIMIT and OFFSET in SQL
EasyInterview Question #7
Given an `articles` table, write a SQL query to retrieve page 3 of articles, where each page contains 10 articles. Sort articles by `published_at` descending.
Input Table: articles
25 rows preview| article_id | title | published_at |
|---|---|---|
| 1 | Data Trends 2026 | 2026-03-30 |
| 2 | SQL Guide | 2026-03-29 |
| 3 | Article 3 | 2026-03-28 |
| 4 | Article 4 | 2026-03-27 |
| 5 | Article 5 | 2026-03-26 |
| 6 | Article 6 | 2026-03-25 |
| 7 | Article 7 | 2026-03-24 |
| 8 | Article 8 | 2026-03-23 |
| 9 | Article 9 | 2026-03-22 |
| 10 | Article 10 | 2026-03-21 |
| 11 | Article 11 | 2026-03-20 |
| 12 | Article 12 | 2026-03-19 |
| 13 | Article 13 | 2026-03-18 |
| 14 | Article 14 | 2026-03-17 |
| 15 | Article 15 | 2026-03-16 |
| 16 | Article 16 | 2026-03-15 |
| 17 | Article 17 | 2026-03-14 |
| 18 | Article 18 | 2026-03-13 |
| 19 | Article 19 | 2026-03-12 |
| 20 | Article 20 | 2026-03-11 |
| 21 | Article 21 | 2026-03-10 |
| 22 | Article 22 | 2026-03-09 |
| 23 | Article 23 | 2026-03-08 |
| 24 | Article 24 | 2026-03-07 |
| 25 | Article 25 | 2026-03-06 |
Expected Output Structure1 rows
| article_id | title | published_at |
|---|---|---|
| 21 | Article 21 | 2026-03-10 |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.