Imagine the following exemplary table:
time name value1 value2
12:00 Hans 2 4
12:30 Hans 2 4
13:00 Hans 3 5
14:00 Peter 4 4
15:00 Peter 4 4
I want to filter by maximum time stamp and name.
Meaning I want to get
13:00 Hans 3 5
15:00 Peter 4 4
Using select max(time),name,value1,value2 from table group by name
does not work. It tells me to use an aggregate function or group by on value1 and value2 also.
If I group by name, value1 and value2 then I get the following result though since value1 and value2 are different for two rows of Hans:
12:30 Hans 2 4
13:00 Hans 3 5
15:00 Peter 4 4
What is the solution?
PostgreSQL, or a shorterPostgres.