Oracle - Count groups in group by I have the following query:

SELECT substr("Timestamp", 1, 16) "Timestamp", "Action", count(*) "Count"
FROM "MyTable" 
WHERE substr("Timestamp", 1, 13) &lt;= substr(CURRENT_DATE, 1, 13)  
GROUP BY substr("Timestamp", 1, 16), "Action"
ORDER BY substr("Timestamp", 1, 16) DESC, "Action"


I want to do paging on the group, so that I e.g. get with page 1 and page-size 2 the first 2 groups with the corresponding elements.

I set up a fiddle for a better understanding. Please see: http://rextester.com/GLY48637

How can I get this paging working?
I found a solution for my problem. I can build a "group-index" and skip/take only the elements in the index. See the following script:

SELECT *
FROM
(
   SELECT x.*, ceil((rank() over (order by x."Timestamp") +
       count(1) over (partition by x."Timestamp"))/6) as pageindex
   FROM 
   (
      SELECT substr("Timestamp", 1, 16) "Timestamp", "Action", count(*)  "Count"
      FROM "MyTable" 
      WHERE substr("Timestamp", 1, 13) &lt;= substr(CURRENT_DATE, 1, 13)  
      GROUP BY substr("Timestamp", 1, 16), "Action"
      ORDER BY substr("Timestamp", 1, 16) DESC, "Action"
   ) x
)
WHERE pageindex &gt; (:page - 1) * :pageSize and pageIndex &lt;= :page * :pageSize