I looking for how to counting time by partition in condition if value=1 occurs consecutively 3 or more times count 1 activity.

Showing result on this picture enter image description here

  • With if value 1 => 3 times, do you mean that there have to be 3 or more consecutive events, and that is why ID 8 and 9 is not taken into consideration? – Lennart Jan 28 at 6:08
  • That correct!! and ID 8 and 9 the data not important, It should be cutoff. – wiroon pimprom Jan 28 at 6:16
  • What is "timespending"? If the time diff betweel lowest and greatest in a frame - why 3 and 4 for activities 2 and 3 (must be 2 and 3 respectively), if records count - why 5 for activity 1 (must be 6)... – Akina Jan 28 at 7:21
  • And specify MySQL version - it is critical in that task. For 8+ you can use something like this. – Akina Jan 28 at 7:22
  • 1
    If you want to draw more attention to your question, either post CREATE TABLE statement together with INSERT statements for sample data or create a db<>fiddle or similar. – Lennart Jan 28 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.