应该是这个意思吧,用普通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(-0){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
页:
[1]