row count with group by on multiple fields

83 views
Skip to first unread message

rohith reddy

unread,
Jul 7, 2016, 5:21:04 PM7/7/16
to Querydsl
hi ,

I am trying to get total row count with a group by expression Using JPAquery in queryDSL. I am grouping on more than one column. 

I need count of 26  grouped records in below example.

SELECT Shippers.ShipperName, Employees.LastName, COUNT(Orders.OrderID) AS NumberOfOrders
FROM ((Orders
INNER JOIN Shippers
ON Orders.ShipperID=Shippers.ShipperID)
INNER JOIN Employees
ON Orders.EmployeeID=Employees.EmployeeID)



Output of above query:


rohith reddy

unread,
Jul 12, 2016, 3:18:01 PM7/12/16
to Querydsl
 i did jpaQuery.list(Wildcard.count).size(); . before applying limit and offset, it worked. still wondering, if there is a better way to do this.

timowest

unread,
Jul 16, 2016, 2:38:27 AM7/16/16
to Querydsl
Instead if group by try a distinct count, that should be faster.
Reply all
Reply to author
Forward
0 new messages