根据楼主给出的结果,可以推测是要统计在qh有序的情况下两个kjh为包含01,02,03,04,05之间的所有kjh不是01,02,03,04,05组成的所有记录数,判断出最大值(历史最大遗漏)和距离最近包含的01,02,03,04,05的所有记录数(当前遗漏) 应该是这个意思吧,用普通sql没想到怎么处理,用mysql的存储过程写了一个统计最大值的(存储过程写的很矬,请不要嘲笑) create table t_one( RecNo int primary key auto_increment, QH int unique not null, KJH varchar(14) not null ); -- 这个表存储了楼主截图中的数据 drop procedure if exists simpleCount; create procedure simpleCount(out param int) BEGIN declare temp int default 0; declare tempTotal int default 0; declare tmpKjh varchar(20); declare done int default 0; declare rs cursor for select kjh from t_one order by qh desc; declare continue handler for sqlstate '02000' set done=1; open rs; repeat fetch next from rs into tmpKjh; if not done then if tmpKjh regexp '0[1-5](-0[1-5]){4}' then -- 这个正则为了判断那个无序包含01,02,03,04,05的条件 if temp >= tempTotal then set tempTotal= temp; set temp = 0; end if; else set temp=temp+1; end if; end if; until done end repeat; close rs; set param = tempTotal; if temp >= tempTotal then set param = temp; end if; END |
什么个意思?怎么算遗漏? |
|申请友链|小黑屋|Archiver|手机版|MySQL社区
( 京ICP备07012489号 )
联系人:周生; 联系电话:13911732319
GMT+8, 2024-5-19 20:35 , Processed in 0.069853 second(s), 31 queries , Gzip On.
Powered by Discuz! X3.2
© 2001-2013 Comsenz Inc.