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 Michael Kashambuzi <mk...@k2tp.com> on 2003/10/03 14:15:56 UTC

COUNT(*) in Torque

Hi:

I was wondering how one can do the following in Torque.

I have a table people which has rows where the lastname can be repeated
multiple times.  I'm trying to do

SELECT DISTINCT LASTNAME, COUNT(*)
FROM PEOPLE
GROUP BY LASTNAME
ORDER BY LASTNAME ASC

I've generated all the Torque classes for my DB.

I MUST use a LargeSelect given the number of rows that could be returned so
I thought I could somehow use a Criteria object like so

Criteria c = new Criteria();
c.addAscendingOrderByColumn(PeoplePeer.LASTNAME);
c.addGroupByColumn(PeoplePeer.LASTNAME);
c.setDistinct();

LargeSelect ls = new LargeSelect(c, 10, 10);

But how would I get it to return the count?

Or would it be necessary to use the Query class to build my own query which
would mean having to populate the value obejcts myself?



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