R
R
Ruslan2016-06-01 21:44:42
SQL
Ruslan, 2016-06-01 21:44:42

How to calculate the total time of events?

I have a table like:

---------------------
|событие   |  время |
|-------------------|
|событие1  |  время1|
|-------------------|
|событие2  |  время2|
|-------------------|
|событие1  |  время3|
|-------------------|
|событие1  |  время4|
|-------------------|
|событие2  |  время2|
---------------------

The names of the events are unique, the time is in unix time, the question is:
Is it possible to make such a request to get the total time of consecutive identical events?
As a result, I need to get data like: event1: 19:00-19:30, event2: 19:30-19:34, event1: 19:34-19:46, etc.
Well, at the same time how to get the total time in general, like: event 1: 42 minutes, event 2: 4 minutes, etc.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2016-06-02
@rOOse

"event names" here for example, let it be id

That is, by ID we determine the entity. Good. At the beginning of the event, add a message about it. At the end - record ( ID, end). Question: why can't we find the ID record and write down the end time in the "End" field of this record ? And we get everything you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question