I have been searching for the last few days for a solution to a
COUNT DISTINCT problem but I have yet to find a resolution. In a reporting application, I need to perform an aggregation SQL statement as follows:
Code:
SELECT tbl.salesRep as X,
COUNT(DISTINCT tbl.item, tbl.vendor) as Y
FROM mySalestable tbl
WHERE facilityId in (:facilityIds)
GROUP BY tbl.salesRep
When using HQL I get the following error:
org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found ',' near line 1, column 61Is this not possible? Can someone show me how to do this with either HQL or Criteria API?