Sample Header Ad - 728x90

Fetch 10 paginated ranked posts of each category

1 vote
1 answer
841 views
Posts table as p:
| id | cid | score | ...
--------------------
|  1 |  1  |   3   | ...
Categories Table as c:
| id |...
--------------------
|  1 |...
What i need? Reterive paginated ranked posts in each category. What i did do:
SELECT
	DENSE_RANK() OVER (
    PARTITION BY c.id
    ORDER BY p."score" DESC NULLS LAST) AS ranking,
    p.id,
    count(*) OVER() AS full_count
FROM p								
INNER JOIN c ON c.id=p.cid
offset 20 limit 10
This query will return whole records and affect offset/limit on it. But i need to affect offset/limit on each category, separated.
Asked by user3690884 (13 rep)
May 8, 2019, 10:33 AM
Last activity: Feb 23, 2023, 09:03 AM