Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Inner Select in HQL  RSS feed

Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to represent the following SQL query in HQL.

select time_dim_id,
(select count(*)
from ut_users user2
where user2.user_created_time_dim_id <= time.time_dim_id
) as TotalUsers
from ut_users user1,
ut_time_dim time
where time.time_dim_id = user1.user_created_time_dim_id
group by time_dim_id
order by time_dim_id

Is this possible? I get the following error when I run the query:

Exception: net.sf.hibernate.QueryException: aggregate function expected before ( in SELECT
(select count(*) from UTUserDim user2 where user2.userCreationTimeId = as TotalUsers
from com.plumtree.usagetracker.persist.UTUser user1,
com.plumtree.usagetracker.persist.UTTimeDim time
where user1.userCreationTimeId =
group by
order by

Also, if you know of any work-arounds, that would be great. I am looking to get a running total of users. My report looks like this:

id count(*)
== =========
1 1
2 2
3 5
4 8
5 13
6 27
7 42
8 42
9 50


  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!