row_number() over partition in hql
What is the equivalent of row_number() over partition in hql I have the following query in hql: select s.Companyname, p.Productname, sum(od.Unitprice * od.Quantity - od.Discount) as SalesAmount FROM OrderDetails as od inner join od.Orders as o inner join od.Products as p " + "inner join p.Suppliers as s" + " where o.Orderdate between '2010/01/01' and '2014/01/01' GROUP BY s.Companyname,p.Productname" I want to do partition by s.Companyname where RowNumber <= n . As far as I know you cannot use row_number() neither in HQL nor in JPQL . I propose to use a native SQL query in this case: