Hi, I know this topic has been discussed to death but I see no viable solution and the only semi-work-around I see have no real explanation so I was hoping somebody would enlighten me with the answer. Thanks.
The HQL I need to run is,
"select u.name, count(*) ct from user u group by u.name order by ct desc"
After searching through this forum, now I realize HQL does not allow aliases on the selected columns. So the only possible method to achieve the desired result would be to use the "column number" as somebody proposed. ( eg] ORDER BY col#2)
Now the question is, how do I indicate the column number in HQL? Is it even possible? If not, is there a work-around for this problem?
Yes I'm using MySQL and I understand MySQL's bug is preventing me to have aggregate function in the ORDER BY. But at least MySQL has a work-around to use the aliase. Is there an equivalent in Hibernate?
I'm losing sleep over this matter... please help.
Thanks.
|