想实现什么?
select count(a.kmdm) into v_count from js2k_mid a
where a.nd = '1984' and a.dqbm = '150000'
and exists (select count(b.kmdm) from js2k_mid b
where b.nd = '1984' and b.dqbm = '150000' and
b.kmdm = substr(a.kmdm,1,length(a.kmdm) - 2))
这样不可?
select count(a.kmdm) into v_count from js2k_mid a
where a.nd = '1984' and a.dqbm = '150000'
and exists (select count(b.kmdm) from js2k_mid b
where b.nd = '1984' and b.dqbm = '150000' and
b.kmdm = substr(a.kmdm,1,length(a.kmdm) - 2))
这样不可?
---------- ---------- ----------
1 300 20
1 200 10
1 30 30
2 500 30
2 600 40SQL> select n1,n2,n3 from test a where (select count(*) from test b where b.n2=substr(a.n2,1,2))=1; N1 N2 N3
---------- ---------- ----------
1 300 20
1 30 30SQL>
---------- ---------- ----------
1 300 20
1 200 10
1 30 30
2 500 30
2 600 40SQL> select n1,n2,n3 from test a where (select count(*) from test b where b.n2=substr(a.n2,1,2))=1; N1 N2 N3
---------- ---------- ----------
1 300 20
1 30 30SQL>
好像不能用的
SQL> CREATE OR REPLACE PROCEDURE AAADADFAA
2 IS
3 a1 varchar2(20);
4 a2 varchar2(20);
5 a3 varchar2(20);
6 BEGIN
7 select n1,n2,n3 into a1,a2,a3 from test a where (select count(*) from test b where b.n2=substr(a.n2,1,2))=1;
8 END;
9 /Procedure createdSQL>