|
真的奇怪
SQL>create table t as select 1 a union select 2;
Execute successful.
Use time:5 ms.
SQL>create table t2 as
2 select row_number()over(order by a.a) rn from
3 (select t.a from t,t t1,t t2,t t3,t t4,t t5,t t6,t t7,t t8,t t9)a,
4 (select t.a from t,t t1,t t2,t t3)b
5 ;
Execute successful.
Use time:50 ms.
SQL>create table t1w as select rn from t2 where rn<=10000;
Execute successful.
Use time:20 ms.
SQL>create table t5k as select rn from t2 where rn<=5000;
Execute successful.
Use time:10 ms.
SQL>with a as(select (s.rn-1)*10000+t.rn a from t1w t,t5k s)
2 select substr(a,-1,1)x,sum(a)s from a
3 group by substr(a,-1,1)
4 order by 1;
X | S |
------------------------------------------------------------------------------
Total 0 records.
Use time:22260 ms.
SQL>with a as(select (s.rn-1)*10000+t.rn a from t1w t,t5k s)
2 select substr(a,length(a),1)x,sum(a)s from a
3 group by substr(a,length(a),1)
4 order by 1;
X | S |
------------------------------------------------------------------------------
Total 0 records.
Use time:19680 ms.
用常量是可以的
SQL>select substr('10',length('10'),1) ;
EXPR1 |
------------------------------------------------------------------------------
0|
Total 1 records.
Use time:0 ms.
数值型也能自动转的
SQL>select substr(10,length(10),1) ;
EXPR1 |
------------------------------------------------------------------------------
0|
Total 1 records.
Use time:5 ms.
|
|