create difference column of time series in MySQL I have a table with 2 columns, the date and the value for the date, e.g.

date         value
2015-09-01   15
2015-09-02   17
2015-09-03   21


and I want to create a column with the difference between the value and the value of the last day, like

date         difference
2015-09-01   NULL
2015-09-02   2
2015-09-03   4


Can this be done with MySQL?
Hope this helps. It's SQL Server code, but you should be able to perform the same join on your table with the date_add function.

DECLARE @TABLE TABLE ([Date] Datetime, [Value] int);

INSERT INTO @TABLE VALUES ('2015-Sep-01',11);
INSERT INTO @TABLE VALUES ('2015-Sep-02',13);
INSERT INTO @TABLE VALUES ('2015-Sep-03',15);
INSERT INTO @TABLE VALUES ('2015-Sep-04',20);
INSERT INTO @TABLE VALUES ('2015-Sep-05',68);

SELECT 
    Main.Date, 
    Main.Value - Previous.Value as [Difference]  
FROM @TABLE Main
LEFT OUTER JOIN @TABLE Previous 
    ON Previous.[Date] = DATEADD(DAY,-1, Main.Date);