I want to go from here:
ID ID_HW DATA LAMPADA
305 3517 02-02-2012 00:00 1208
277 3517 30-12-2011 00:00 1127
179 3517 06-12-2011 00:00 1092
134 3517 03-11-2011 00:00 962
89 3517 06-10-2011 00:00 851
69 3517 07-09-2011 00:00 786
42 3517 25-08-2011 00:00 786
306 3518 02-02-2012 00:00 2082
250 3518 30-12-2011 00:00 2045
180 3518 06-12-2011 00:00 2004
163 3518 08-11-2011 00:00 1695
90 3518 06-10-2011 00:00 1516
68 3518 07-09-2011 00:00 1426
43 3518 25-08-2011 00:00 1315
307 3519 02-02-2012 00:00 482
251 3519 02-01-2012 00:00 375
181 3519 06-12-2011 00:00 347
137 3519 07-11-2011 00:00 229
91 3519 06-10-2011 00:00 92
67 3519 07-09-2011 00:00 2305
44 3519 25-08-2011 00:00 2304
to here:
ID_HW MINDATA MAXDATA _DAYS_ CONSUMED
3517 25-08-2011 00:00 02-02-2012 00:00 161 422
3518 25-08-2011 00:00 02-02-2012 00:00 161 767
3519 25-08-2011 00:00 02-02-2012 00:00 161 -1822
Note: For each id_hw, i want the max, min of data, datediff in days, and the dificult part for me is making the diference of the values associated with the date, creating the consumed values in the range.