0

I have a table that selects record every minute. I want to add a column that calculates how much time has passed between my current record and the first record. But I am not sure how to do that.

For example, if my first record has time 2:30, second has time 2:50 and third has time 3:00, then for my new column: time_passed, it will have values 0,20,30.

Thank you in advance!

Will Da Silva
  • 6,386
  • 2
  • 27
  • 52

1 Answers1

0

Assuming your column is of type minute (u/17), you can simply do this:

update time_passed: `int$your_col - first your_col from tbl

This will calculate the underlying number of minutes from first record for each record. If you want to see the result as minutes as well, simply remove the cast to int.

shree.pat18
  • 21,449
  • 3
  • 43
  • 63