Try the following:
SELECT create_time FROM timeTable WHERE create_time IN ( SELECT min( create_time ) FROM timeTable GROUP BY FROM_UNIXTIME( UNIX_TIMESTAMP( create_time ) - MOD( UNIX_TIMESTAMP( create_time ) , 60 ) );
How it works:
i) Groups the table by date rounded to the interval, 1 minute (60 seconds) here.
ii) Gets the top row from each group.
This may be a good selection criterion for your data. This query can be optimized at these points:
i) Put the where clause for the date = REQUIRED DATE, and then do other operations for an hour + minutes instead of an integer datetime.
ii) If your interval is 1 minute, you can adjust the substring of the timestamp or date_format to round it to the nearest minute.
eg.
SELECT create_time FROM timeTable WHERE create_time IN ( SELECT min( create_time ) FROM timeTable GROUP BY DATE_FORMAT( `create_time` , 'YMD %H:%i' ) );
source share