You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by jill han <jh...@bynum.com> on 2005/09/07 16:14:10 UTC

how to write a criteria involved with count, group

How can I write a criteria that is equivalent to:

SELECT USER_NAME, COUNT(USER_NAME) NUMOFUSERS
FROM USERTABLE
WHERE USER_ID = 0000
GROUP BY USER_NAME;

Thanks in advance.
Jill


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


RE how to write a criteria involved with count, group

Posted by Bertrand VENZAL <be...@cirso.fr>.
I think it will be something like that in your usertablePeer.java file

criteria = new Criteria();
crit.addSelectColumn("COUNT("+ USERNAME+")");
crit.add(USER_ID, 0);
crit.addGroupByColumn(USER_NAME);
List litems = doSelect(crit);

but maybe you can switch the variable COUNT and use the litems.size() ....

hope this help ..






"jill han" <jh...@bynum.com> 
07/09/2005 16:14
Veuillez répondre à
"Apache Torque Users List" <to...@db.apache.org>


A
"Apache Torque Users List" <to...@db.apache.org>
cc

Objet
how to write a criteria involved with count, group






How can I write a criteria that is equivalent to:

SELECT USER_NAME, COUNT(USER_NAME) NUMOFUSERS
FROM USERTABLE
WHERE USER_ID = 0000
GROUP BY USER_NAME;

Thanks in advance.
Jill


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