I have 2 objects, Book and BookEdition. A Book can have many BookEdition (One to Many). I want to select a list of bookEditions with thier corresponding book, with that bookEdition being the one with the highest publication date for that particular book. I want to limit it to say, the top 10 most recent books editions, but do not want duplicate books, so if 2 book editions for the same book are in the top 10, i want only the most recent one.
I also have another query where I would select only bookEditions where the datePublished is in say the last 90 days from today, and sort them by an attribute of the book (book.score), while still having only the most recent bookEdition for a book and no book duplicates.
So my query would begin like this : Select b, be from Book b, BookEdition be Where b.no = be.bookNo Order By be.datePublished Desc limit 10.
This query of course could have duplicate books in it.
I am at a loss in how to do it.
Thanks!
Eric bouchard
|