--需要对如1002002001,后四位以2开头的求和
create table test_1(index_value number,inst_no varchar2(100)) --创建最需要字段
select * from test_1
insert into test_1 values(1,1002002001);
insert into test_1 values(2,1002002002);
insert into test_1 values(3,1002002003);
insert into test_1 values(4,1002002004);
insert into test_1 values(5,1002003001);
insert into test_1 values(1,1002003003);
insert into test_1 values(2,1002003005);
insert into test_1 values(8,1002004001);
insert into test_1 values(7,1002004002);
insert into test_1 values(3,1002005002);
insert into test_1 values(9,1002005001);
insert into test_1 values(4,1002006001);
insert into test_1 values(3,1002006004);
insert into test_1 values(0,1002006007);
insert into test_1 values(null,1002002000);
insert into test_1 values(null,1002003000);
insert into test_1 values(null,1002004000);
insert into test_1 values(null,1002005000);
insert into test_1 values(null,1002006000);
commit;
只查倒数第4位是1的数据,混合left和right函数,当然,这是mysql的语法,你要是其他数据库,百度下对应的函数即可