0
0
PostgreSQLquery~10 mins

FETCH FIRST for SQL standard pagination in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to limit the query to return only the first 5 rows.

PostgreSQL
SELECT * FROM employees ORDER BY employee_id [1] 5 ROWS ONLY;
Drag options to blanks, or click blank then click option'
AROWNUM
BLIMIT
CTOP
DFETCH FIRST
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-standard keywords like TOP or ROWNUM which are not supported in PostgreSQL.
Confusing FETCH FIRST with LIMIT syntax.
2fill in blank
medium

Complete the code to fetch the first 10 rows only.

PostgreSQL
SELECT name, salary FROM staff ORDER BY salary DESC [1] 10 ROWS ONLY;
Drag options to blanks, or click blank then click option'
AFETCH FIRST
BFETCH NEXT
CFETCH LAST
DFETCH PRIOR
Attempts:
3 left
💡 Hint
Common Mistakes
Using FETCH NEXT without OFFSET when wanting the first rows.
Using FETCH LAST which is invalid.
3fill in blank
hard

Fix the error in the query to correctly fetch the next 5 rows after skipping 10 rows.

PostgreSQL
SELECT * FROM orders ORDER BY order_date [1] 10 ROWS [2] 5 ROWS ONLY;
Drag options to blanks, or click blank then click option'
AOFFSET
BFETCH NEXT
CFETCH FIRST
DLIMIT
Attempts:
3 left
💡 Hint
Common Mistakes
Using FETCH FIRST instead of FETCH NEXT for pagination.
Using LIMIT instead of OFFSET and FETCH.
4fill in blank
hard

Fill both blanks to paginate: skip 20 rows and fetch the next 10 rows.

PostgreSQL
SELECT product_id, price FROM products ORDER BY price DESC [1] 20 ROWS [2] 10 ROWS ONLY;
Drag options to blanks, or click blank then click option'
AOFFSET
BFETCH NEXT
CFETCH FIRST
DLIMIT
Attempts:
3 left
💡 Hint
Common Mistakes
Using FETCH FIRST instead of FETCH NEXT for the second blank.
Using LIMIT instead of OFFSET and FETCH.
5fill in blank
hard

Fill all three blanks to select customer names, skip 15 rows, and fetch the next 7 rows only.

PostgreSQL
SELECT [1] FROM customers ORDER BY customer_id [2] 15 ROWS [3] 7 ROWS ONLY;
Drag options to blanks, or click blank then click option'
Acustomer_name
BOFFSET
CFETCH NEXT
DLIMIT
Attempts:
3 left
💡 Hint
Common Mistakes
Using LIMIT instead of OFFSET and FETCH.
Selecting wrong column name.