Hi,

I have the following problem: I have a table (Entities) with the following 
columns:

   - EntityId
   - Time (of change)

For each entity I want to find the one that changed most recently (largest 
time).

So far my query looks like this:

SELECT    i.EntityId, 
  i.TimeFROM    
  Entities i INNER JOIN    (      SELECT  EntityId,              MAX(time) 
maxTime      FROM    Entities      GROUP BY EntityId    ) sMax  ON  i.EntityId 
= sMax.EntityId             AND i.Time = sMax.maxTime

It also works, but I have quite some amount of data and it is not as fast as I 
would hope. Does anyone know a way to make
this query faster/more efficiently? Thank you in advance :)

Greetings,
Juna

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to