currently I'm stuck in an issue, hope some good PostgreSQL fellow programmer could give me a hand with it. This is my table...
I would like to SELECT all 'time_elapse' WHERE time_type = 'Break' but only the rows that are after(below) the last(descendent) time_type = 'Start' and sum them up.
So in the table above I would SELECT...
time_elapse | time_type | time_index
----------------------+--------------+-------------
00-00-00 01:00:00.00 | Break | 2.1
00-00-00 01:00:00.00 | Break | 2.2
So totalbreak = 00-00-00 02:00:00.000
I know how to convert character varying to timestamp in order to sum them up (please don't bother with that, I'm not looking for help with that, let's image 'time' and 'time_elapse' columns are proper timestamps), I just don't know how would be the syntax to select all possible 'Breaks' and sum them up (lets say the max Breaks between each 'Start' is nine).
I can hardly imagine a way to do that, so I would like to ask for suggestions.
Aucun commentaire:
Enregistrer un commentaire