You are misusing GROUP BY here. What would you like to get in the result? How does ORDER BY work here?
GROUP BY is intended to be used with statistical functions. To get the result you wrote, I would write the query this way:
SELECT UserId, LocationId, MAX(LastLoginDate) FROM Blah GROUP BY LocationId
Stefan Arentz wrote:
On Nov 25, 2003, at 10:33 PM, Bill Burke wrote:
Unfortunately EJB QL only allows 1 item in the select statement so no GROUP BY. Use Hibernate.
Even then GROUP BY on one table is useful. For example to change this:
UserId LocationId LastLoginDate 1 1 2003-01-01 1 1 2003-01-10 1 1 2003-01-12 1 2 2003-02-01 1 2 2003-03-12 2 1 2003-03-03 2 1 2003-04-05
into this:
UserId LocationId LastLoginDate 1 2 2003-03-12 2 1 2003-04-05
using something like:
select * from Blah group by LocationId order by Date desc;
There is no easy way to do this without GROUP BY.
S.
------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ JBoss-Development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ JBoss-Development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development