1. 程式人生 > >統計某個欄位中各個字元出現的次數

統計某個欄位中各個字元出現的次數

select 'hhjdbgydgdjd' str from dual union all select 'jdujgbhdg' str from dual union all select '514dgj1fgy' str from dual ) --構建臨時表 select t1.str,/*t1.str,t2.lv,*/substr(t1.str,t2.lv,1) alp,count(substr(t1.str,t2.lv,1)) cnt from t1 left join (select level lv from dual connect by level < 20) t2 on
1=1 --level的值視欄位長度而定 where substr(t1.str,t2.lv,1) is not null group by t1.str,substr(t1.str,t2.lv,1) order by t1.str,count(substr(t1.str,t2.lv,1)) desc ;