Thanks for the reply , will give the above a go.
Sorry for poor explanation.
Current row = the row i am querying , bearing in mind i need to query all rows per device.
Previous row = the row prior to the one i am looking at per device.
Arrived at 3 and 5 because when reading row 5 the value is > 20 when compared to the previous (row 4) for that devices.
Sorry , finding it hard to explain , easier to show.
Scott
Edit to say, not sure is UNION is a good idea, find it very slow on + billions records.