MySQL Forums
Forum List  »  Newbie

Re: Need query help to create intervals
Posted by: veerabhadrarao gandikota
Date: August 17, 2022 09:00AM

Hi Peter,

Thanks for your response. Can you please provide a query.

We are using below query but its not working properly.



SELECT ACTIVITY_LABEL, date_sub(min(ACTIVITY_TS),interval 1 second) as start_time, max(ACTIVITY_TS) as end_time from (

select ACTIVITY_LABEL,ACTIVITY_TS,

ROW_NUMBER() OVER (PARTITION BY DATE(ACTIVITY_TS) ORDER BY ACTIVITY_TS) AS seqnum,

ROW_NUMBER() OVER (PARTITION BY DATE(ACTIVITY_TS),activity_label ORDER BY ACTIVITY_TS) AS seqnum_2 from MyTable

order by ACTIVITY_TS

) group by ACTIVITY_LABEL, date(ACTIVITY_TS),(seqnum - seqnum_2)

order by start_time



Thanks,
Veera

Options: ReplyQuote


Subject
Written By
Posted
Re: Need query help to create intervals
August 17, 2022 09:00AM


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.