MySQL Forums
Forum List  »  Newbie

Need query help to create intervals
Posted by: veerabhadrarao gandikota
Date: August 15, 2022 05:21PM

Hi,

I need help in query to get intervals of event and timestamp (if there is a gap of 1 second in the same label, we need an additional interval). below are the samples and expected results.


Input
--------------------------------------
Label time
Sleep 08/15/2022 00:00:01
Sleep 08/15/2022 00:00:02
Sleep 08/15/2022 00:00:03
Sleep 08/15/2022 00:00:04
Sleep 08/15/2022 00:00:05
Sleep 08/15/2022 00:00:06
Resting 08/15/2022 00:00:07
Resting 08/15/2022 00:00:08
Resting 08/15/2022 00:00:09
Walk 08/15/2022 00:00:10
Walk 08/15/2022 00:00:11
Resting 08/15/2022 00:00:15
Resting 08/15/2022 00:00:16
Resting 08/15/2022 00:00:17
Resting 08/15/2022 00:00:30
Resting 08/15/2022 00:00:31
Resting 08/15/2022 00:00:32

Expected output is
-------------------------
Sleep 08/15/2022 00:00:01 to 08/15/2022 00:00:06
Resting 08/15/2022 00:00:07 to 08/15/2022 00:00:09
Walk 08/15/2022 00:00:10 to 08/15/2022 00:00:11
Resting 08/15/2022 00:00:15 to 08/15/2022 00:00:17
Resting 08/15/2022 00:00:30 to 08/15/2022 00:00:32

Thank you,
Veera

Options: ReplyQuote


Subject
Written By
Posted
Need query help to create intervals
August 15, 2022 05:21PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.