PDA

View Full Version : TIMESTAMPDIFF from one column (SQL Server)



M_8
08-19-2022, 08:02 AM
Hi,
I'm new to SQL Server and i have question:
Is it even possible to somehow use TIMESTAMPDIFF to calculate values from same column?
I mean some kind of loop that will calculate TIMESTAMPDIFF(SECOND, Value.row1, Value.row2) and puts it in next column in row1.
Table has variable amount of rows (usualy 20k+, depending on query details).


Or any other idea how to calculate TIMESTAMPDIFF if each data is in separate row, like in this excel example:
https://i.ibb.co/0qzZ6PL/timestampsexe.png (https://ibb.co/qB29cb8)

Now it's solved by feeding raw data into PowerBI/PowerQuery but it isnt perfect, not to mention tons of .csv/.xls files on shared disk and lack of those timestamps diff in SQL database :(

arnelgp
08-19-2022, 10:32 PM
here is a demo.

M_8
08-20-2022, 01:00 AM
Yea, but this is just excel macro (or im missing something).
I'm looking for a way to implement this on SQL Server database.
I don't have access to this database on weekends, mybe on monday i will make some screens on how it looks right now in SQL.