db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jill han" <j...@bynum.com>
Subject How to round a avg
Date Mon, 31 Oct 2005 20:15:41 GMT
I tried to get a query like:

Select id, round(avg(rating), 2)
>From aTable
Where aId = 11111 and rating > 1
Group by(id);

by the codes:

Criteria crit = new Criteria();
crit.add(aTablePeer.a_ID, 11111);
crit.add(aTablePeer.RATING, 1, Criteria.GREATER_THAN);
crit.addSelectColumn(aTablePeer.ID);
crit.addSelectColumn("ROUND(AVG("+aTablePeer.RATING + "), 2)");
crit.addGroupByColumn(aTablePeer.ID);
List result = aTablePeer.doSelect(crit);
Log.debug("query is " + crit.toString());

However, the above codes caused an exception: 
Turbine.handleException: java.lang.Exception:
org.apache.torque.TorqueException: ORA-00933: SQL command not properly
ended

When I checked the debug code, somehow, the codes were interpreted as 
SELECT aTable.ID, Round(AVG(aTable.RATING), 2) FROM aTable, AVG(aTable 
WHERE aTable.RATING>1 AND aTable.a_ID=11111 

How could ", Avg(aTable" append to From clause?

Thanks in advance.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message