This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I have been trying to create a query for three days now and can't seem to get it to work correctly. Would really appreciate some guidance... Here's my problem
-I have a function that returns a list of <Event> objects from the query (Event is a class that I created to hold events that occur due to a Problem [another Class I created])
-I want to return the all Events that are associated with a Probelm ID
-I do not want to return Events with identical descriptions (because they are the same event) but instead only the one that occured last (Event Max(e.creationDate))
-I would like to Order By creationDate
I am gues my query may need an INNER JOIN, I also tried the DISTINCT keyword.. Here is the script I feel is the closet to what I want..
SELECT * FROM Event e INNER JOIN FETCH (SELECT DISTINCT e.description, MIN(e.id) AS id FROM Event e GROUP BY e.description) AS tmpTable ON e.description = tmpTable.description AND (e.id = tmpTable.id);
I would super appreciate any help.. THANK YOU in advance..