SELECT
[current].rowInt,
[current].Value,
ISNULL([next].Value, 0) - [current].Value
FROM
sourceTable AS [current]
LEFT JOIN
sourceTable AS [next]
ON [next].rowInt = (SELECT MIN(rowInt) FROM sourceTable WHERE rowInt > [current].rowInt)
EDITAR:
Pensándolo bien, usar una subconsulta en la selección (la respuesta de ala Quassnoi) puede ser más eficiente. Probaría diferentes versiones y miraría los planes de ejecución para ver cuál funcionaría mejor en el tamaño del conjunto de datos que tiene...
EDIT2:
Todavía veo que esto obtiene votos, aunque es poco probable que mucha gente todavía use SQL Server 2005.
Si tiene acceso a funciones de ventana como LEAD()
, luego usa eso en su lugar...
SELECT
RowInt,
Value,
LEAD(Value, 1, 0) OVER (ORDER BY RowInt) - Value
FROM
sourceTable