-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: how to convert round(sum(c11*count)/sum(count),2) c11 in HQL
PostPosted: Mon May 24, 2010 5:47 am 
Beginner
Beginner

Joined: Fri Sep 28, 2007 4:58 am
Posts: 21
Location: Chennai, India
Hi,

please let me know how to convert the below SQL query in HQL.

SELECT date1, ID, c1,c2,c3,round(sum(c11*count)/sum(count),2) c11,SUM(count) count FROM xxx WHERE date1 >= ? AND date1 <= ? AND ID = ? GROUP BY date1,c1,c2,c3

Here count is a column in the table.

when i converted into HQL i got the below error.
Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: expecting OPEN, found ')' [SELECT date1, Id,c1,c2,c3, round(sum(c11*count)/sum(count),2) c11,SUM(count) count FROM xxx WHERE date1 >= ? and date1 <= ? and Id = ? group by date1, c1,c2,c3]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:258)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at auditcosolidation.HibernateTest.main(HibernateTest.java:54)


Thanks in Adavance.

Regards,
Purushotham

_________________
Purushotham Podaralla


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.