;declare thisname varchar(10)
;declare done tinyint default 0;declare cur cursor for select dtime,name from `table`
;declare continue handler for sqlstate 2000 set done=1;create temporary table if not exists `tmp`(dtime datetime, name varchar(10));while done1 doif lastdtime is null thenfetch cur into lastdtime,lastname;elsefetch cur into thisdtime,thisname;if timediff(thisdtime,lastdtime)>