db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jerry Brenner" <jbren...@guidewire.com>
Subject RE: COUNT(*) in Torque
Date Fri, 03 Oct 2003 16:48:08 GMT
I'm not using Torque, just monitoring the mailing list in case we move in that direction. 


The DISTINCT in your query is unnecessary (and will probably be removed by the optimizer anyway).
 The GROUP BY makes the DISTINCT redundant.

-----Original Message-----
From: Michael Kashambuzi [mailto:mkashambuzi@k2tp.com]
Sent: Friday, October 03, 2003 5:16 AM
To: torque-user@db.apache.org
Subject: 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


---------------------------------------------------------------------
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