回覆列表
  • 1 # 使用者106685549569

    這個得用儲存過程了,一句話查詢肯定解決不了。delimiter //Create Procedure findtime()Begindeclare lastdtime datetime default null;declare thisdtime datetime default null;declare lastname varchar(10);declare thisname varchar(10);declare done tinyint default 0;declare cur cursor for select dtime,name from `table`;declare continue handler for sqlstate "02000" 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)>"00:05:00" theninsert into `tmp` (dtime,name)values(lastdtime,lastname);set lastdtime=thisdtime;set lastname=thisname;end if;end if;end while;select * from `tmp`;End//call findtime()//

  • 2 # 使用者106685549569

    這個得用儲存過程了,一句話查詢肯定解決不了。delimiter //Create Procedure findtime()Begindeclare lastdtime datetime default null;declare thisdtime datetime default null;declare lastname varchar(10);declare thisname varchar(10);declare done tinyint default 0;declare cur cursor for select dtime,name from `table`;declare continue handler for sqlstate "02000" 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)>"00:05:00" theninsert into `tmp` (dtime,name)values(lastdtime,lastname);set lastdtime=thisdtime;set lastname=thisname;end if;end if;end while;select * from `tmp`;End//call findtime()//

  • 中秋節和大豐收的關聯?
  • 但是不知道好玩不誰能介紹一下天台山在邛崍的那個?