db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sasikumar Natarajan <nsasi_...@yahoo.com>
Subject Re: how can i write torque Group By Query
Date Mon, 01 Dec 2008 05:30:23 GMT
Hello ALL,
           i have been developed a oracle query for getting employees count in each
department as given below. This query i want to change Torque Query as Similar functionality
by using Peer Class Joint. Can u Please help me for converting by using Peer Class Joint.
 
SELECT DEPT_NUMBER, DEPT_NAME, COUNT(DEPT_NUMBER) NUMBER_OF_EMPLOYEES FROM EMPLOYEES EMP,
DEPARTMENTS DEPT
WHERE EMP.EMP_DEPT_NUMBER = DEPT.DEPT_NUMBER GROUP BY DEPT_NUMBER, DEPT_NAME 

Thanks In Advance
Sasikumar

--- On Wed, 26/11/08, Sasikumar Natarajan <nsasi_cts@yahoo.com> wrote:

From: Sasikumar Natarajan <nsasi_cts@yahoo.com>
Subject: how can i write torque Group By Query
To: "Apache Torque Users List" <torque-user@db.apache.org>
Date: Wednesday, 26 November, 2008, 12:39 PM

Hi All
 
The following query i need to change by using torque query.
 
SELECT DEPT_NUMBER, DEPT_NAME, COUNT(DEPT_NUMBER) NUMBER_OF_EMPLOYEES FROM
EMPLOYEES EMP, DEPARTMENTS DEPT
WHERE EMP.EMP_DEPT_NUMBER = DEPT.DEPT_NUMBER GROUP BY DEPT_NUMBER, DEPT_NAME 
 
i did the following by using torque query. but this is wrong. 
 
Please help me to correct the following query.
 
Criteria criteria = new Criteria();
criteria.addSelectColumn(DepartmentPeer.DEPT_NUMBER);
criteria.addSelectColumn(DepartmentPeer.DEPT_NAME);

criteria.addGroupByColumn(DepartmentPeer.DEPT_NUMBER);
criteria.addGroupByColumn(DepartmentPeer.DEPT_NAME);

criteria.addJoin(EmployeePeer.EMP_DEPT_NUMBER, DepartmentPeer.DEPT_NUMBER);
List deptList = DepartmentPeer.doSelect(criteria);
 
Thanks in Advance
Sasikumar


      Unlimited freedom, unlimited storage. Get it now, on
http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/


      Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message