Calculate difference between two consecutive rows

See this discussion