Can't find difficult SELECT query

T

Tommy DN

I can't find a select-query, but first I'm going to explain the
situation:

This can be a example of my table ( in real, it's more sophisticated
):
" Value " and " Time " are the fieldnames.

Value Time
* 1 1 *
2 1
3 1
* 2 2 *
3 2
* 3 3 *
* 4 4 *

So, I only need to select the Value with the highest Time ( Time and
Value are both integer (number) - fields ). The result must be what
I've set between '*':
Result:

Value Time
* 1 1 *
* 2 2 *
* 3 3 *
* 4 4 *

Does someone know I SQL-command for it?
 
J

Joop Kuijntjes

I can't find a select-query, but first I'm going to explain the
situation:

This can be a example of my table ( in real, it's more sophisticated
):
" Value " and " Time " are the fieldnames.

Value Time
* 1 1 *
2 1
3 1
* 2 2 *
3 2
* 3 3 *
* 4 4 *

So, I only need to select the Value with the highest Time ( Time and
Value are both integer (number) - fields ). The result must be what
I've set between '*':
Result:

Value Time
* 1 1 *
* 2 2 *
* 3 3 *
* 4 4 *

Does someone know I SQL-command for it?

This will do the trick:

SELECT Table1.Value, Max(Table1.Time) AS MaxOffTime
FROM Table1
GROUP BY Table1.Value
ORDER BY Table1.Value;

Joop
 
Top