-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: how to group by max(date)?
PostPosted: Thu Nov 05, 2009 5:52 am 
Regular
Regular

Joined: Tue Apr 10, 2007 10:02 am
Posts: 56
I'm struggling to build a HQL query against a customer invoice table where I want to return a list of the most recent invoices for each customer but across all customers, like...

Here's a sample full table...
Code:
[customer id] [invoice date] [invoice number] [invoice value]
       1             2009/10/1         3511               44,567.56
       1             2009/10/15       4512               17,333.56
       2             2009/10/4         2222               23,954.56
       2             2009/10/7         5555              75,567.56
       3             2009/10/3         6655               81,000.56
       3             2009/10/18       3888               71,123.56

.. and my HQL query should return just the latest invoices for each customer, like...
Code:
[customer id] [invoice date] [invoice number] [invoice value]
       1             2009/10/15       4512               17,333.56
       2             2009/10/7         5555              75,567.56
       3             2009/10/18       3888               71,123.56


Any ideas?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.