time stamp meter name parameter name value 2014-02-18 18:58:00 1$SGP A 415.7806091308594 2014-02-18 18:58:00 1$SGP B 240.3373565673828 2014-02-18 18:58:01 2$SGP A 393.191162109375 2014-02-18 18:58:02 2$SGP B 50.10090637207031 2014-02-18 18:58:00 3$SGP A 3484841472 2014-02-18 18:05:01 1$SGP A 0 2014-02-18 17:58:01 1$SGP A 0 2014-02-18 17:58:01 2$SGP A 290 2014-02-18 17:58:01 2$SGP D 0 2014-02-18 17:58:01 3$SGP A 3061691904 2014-02-18 17:57:01 3$SGP A 0 2014-02-18 17:57:02 3$SGP B 0
find the difference in time stamps of two consecutive time stamp and the difference in their value for each individual meter for a particular parameter.
Expected Output: for 18:58
01:00 1$SGP 415.7806091308594-0
01:00 2$SGP 393.191162109375-290
01:00 3$SGP 3484841472-3061691904
At, 18:58 1$SGP,2$SGP and 3$SGP throwing values for parameter A. At 17:58 1$SGP,2$SGP and 3$SGP throwing values for parameter A. Rest either all meters are not present together for a time stamp as in 18:05 Seconds can be ignored in the time stamp. So,
01:00 1$SGP 415.7806091308594-0 01:00 2$SGP 393.191162109375-290 01:00 3$SGP 3484841472-3061691904
Facing problem in coming up with the query in MS SQL. I am also not familiar with the convert method for ignoring the second which in mysql can be dealth with date_format().