group some records and Ignore some differences in grouping records in mysql (PROBLEM IN GROUPING)

Viewed 24

I want to group my records by the time they are modified. (time means the minute)

A screenshot from my table:

My Records in the 'main' table

And the code is:

SELECT GROUP_CONCAT(text) as final_text 
  FROM main WHERE HSA = 'YES' 
 GROUP BY SUBSTRING(timestamps,1,16);

the result is:

RESULT

you can see that 4 of my records are modified at 12:23 , 4 of them at 12:35 and one of them at 12:36.

But, I want mysql to group all records together if they are less than two minutes apart (ignore differences less than 2 minutes!)

Please help me how to add my last record to the second group

0 Answers
Related