Counting number of consecutive days and only use greater than X days
1007410May 7 2013 — edited May 8 2013I am using database version 11.2.0.1.0
I have data that looks like this:
ID Date: Value
55 2-24-2013 120
55 2-25-2013 126
55 2-26-2013 120
55 2-27-2013 130
55 3-01-2013 110
55 3-02-2013 126
55 3-05-2013 130
72 2-28-2013 120
72 3-01-2013 126
72 3-02-2013 120
72 3-10-2013 130
72 3-11-2013 110
72 3-12-2013 126
72 3-13-2013 130
So I would like to detemine the data that has more then 2 consecutive days and then take the change in value to get data like this.
ID Date: Value Delta
55 2-24-2013 120 Null
55 2-25-2013 126 6
55 2-26-2013 120 -6
55 2-27-2013 130 10
72 2-28-2013 120 Null
72 3-01-2013 126 6
72 3-02-2013 120 -6
72 3-10-2013 130 Null
72 3-11-2013 110 -20
72 3-12-2013 126 16
72 3-13-2013 130 -4
Any suggestions???? I am using SQL Developer 3.0.04 for this.
Edited by: 1004407 on May 7, 2013 9:03 AM
Edited by: 1004407 on May 7, 2013 9:11 AM