本帖最后由 yhdata_aqziecpj 于 2023-8-16 21:49 编辑
抱歉,之前没表达清楚。我想要的是产品合格率连续三月小于0.98的所有信息,不是平均合格率。如下:
比如甲产品,2,3,4连续三月合格率小于0.98,我要月份、产品、合格率三个字段,下图标黄部分
img
创表语句如下
create table detection(
month int comment'月份',
product char(2) comment'类型',
rate double comment'合格率'
) comment'抽查表';
insert into detection values (1,'甲', 0.98);
insert into detection values (1,'乙', 0.99);
insert into detection values (1,'丙', 0.96);
insert into detection values (2,'甲', 0.97);
insert into detection values (2,'乙', 0.95);
insert into detection values (2,'丙', 0.96);
insert into detection values (3,'甲', 0.94);
insert into detection values (3,'乙', 0.99);
insert into detection values (3,'丙', 0.90);
insert into detection values (4,'甲', 0.97);
insert into detection values (4,'乙', 0.96);
insert into detection values (4,'丙', 0.89);
insert into detection values (5,'甲', 0.99);
insert into detection values (5,'乙', 0.92);
insert into detection values (5,'丙', 0.96);
insert into detection values (6,'甲', 0.97);
insert into detection values (6,'乙', 0.96);
insert i detectintoon values (6,'丙', 0.97); |