1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Compute diff between values of same column depending on datetime?

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 26, 2024 às 05:13.

  1. Stack

    Stack Membro Participativo

    I have a mssql db which looks like this:

    id | price | date |version
    1 | 10 |2020-06-01| 1
    2 | 15 |2020-06-12| 2
    3 | 4 |2020-06-03| 1
    4 | 5 |2020-06-04| 2
    5 | 5.5 |2020-06-10| 3


    What I want to do is to compute the difference between first two rows. For example, I want to compute 15- 10. These are the values for 2020-06-01 and 2020-06-01. How could I do this? I have tried several sql statements but without success.

    Continue reading...

Compartilhe esta Página