0
What I have to use in SQL SERVER 2008 to get the line before a certain enclosure. For example if in my Where below if the alert is = to 99 want to know the alert and the speed before the alert.
Speed Data Alerta
58 '2017-09-13 10:08:04.290' 44
20 '2017-09-13 10:08:51.340' 99
56 '2017-09-13 10:09:21.450' 204
40 '2017-09-13 10:09:27.470' 99
34 '2017-09-13 10:09:37.570' 204
In this example there were two alert 99 where he was at a speed of 20 and 40 km, I want to return this previous line to the alert with the highest speed:
Speed Data Alerta
56 '2017-09-13 10:09:21.450' 204
Wouldn’t be the 58 '2017-09-13 10:08:04.290' 44 higher speed ?
– Marco Souza
Possible duplicate of How to use LEAD and LAG using a condition
– Sorack
@Marcelomartins: Does the table have a column that uniquely identifies each row? That is, does it have a primary key? // And if there is more than one alert 99, but at the same speed?
– José Diz