Hello group,
I have a table with the next contents.
It lists data about : Who sent what kind of message at what time.
For the Level column: The highest level is Critical, the middle is Warning,
the lowest is Info.
Id Timestamp Level
1 12:00 Info
1 13:00 Warning
1 14:00 Critical
2 12:00 Info
2 13:00 Warning
2 14:00 Info
2 15:00 Warning
3 12:00 Critical
3 13:00 Warning
4 15:00 Info
5 15:00 Info
5 16:00 Warning
What I want to get out of his list is:
The first message with the highest level of each Id. So let the Level-column
prevail above the Timestamp column,so I want to get this result:
1 14:00 Critical // The only 'Critical'
2 13:00 Warning // the first 'Warning'
3 12:00 Critical // The only 'Critical'
4 15:00 Info // The only one, so simple
5 16:00 Warning // The highest level, the only
'Warning'
So: First find the highest level of message of each Id and then find the
first one.
The first part I tried with CASE .. THEN .. END construction.
Any hints appreciated.
Gr, Hans
I have a table with the next contents.
It lists data about : Who sent what kind of message at what time.
For the Level column: The highest level is Critical, the middle is Warning,
the lowest is Info.
Id Timestamp Level
1 12:00 Info
1 13:00 Warning
1 14:00 Critical
2 12:00 Info
2 13:00 Warning
2 14:00 Info
2 15:00 Warning
3 12:00 Critical
3 13:00 Warning
4 15:00 Info
5 15:00 Info
5 16:00 Warning
What I want to get out of his list is:
The first message with the highest level of each Id. So let the Level-column
prevail above the Timestamp column,so I want to get this result:
1 14:00 Critical // The only 'Critical'
2 13:00 Warning // the first 'Warning'
3 12:00 Critical // The only 'Critical'
4 15:00 Info // The only one, so simple
5 16:00 Warning // The highest level, the only
'Warning'
So: First find the highest level of message of each Id and then find the
first one.
The first part I tried with CASE .. THEN .. END construction.
Any hints appreciated.
Gr, Hans
Comment