db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sasikumar Natarajan <nsasi_...@yahoo.com>
Subject how can i write torque Group By Query
Date Wed, 26 Nov 2008 12:39:42 GMT
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/
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message