17,086
社区成员
发帖
与我相关
我的任务
分享
with tb as (select '1100001111' right from dual
union all select '1100101111' from dual union all
select '1101001111' from dual
)
select replace(wm_concat(case when substrb(sum_right,rownum,1)=0 and
substrb(sum_right,10+ rownum,1)=0 and substrb(sum_right,20+rownum,1)=0
then 0 else 1 end),',','')
from(select replace(wm_concat(right),',','') sum_right from tb ) connect by rownum<=10
create or replace function FUNC_TO_NUMBER(STR in varchar2) return number is
result number(10) := 0;
len number(20);
begin
len := lengthb(STR);
for i in 1 .. len
loop
result := result + substrb(STR, i, 1) * power(2, i - 1);
end loop;
return result;
end FUNC_TO_NUMBER;
create or replace function FUNC_TO_CHAR(NUM number) return varchar2 is
result varchar2(10);
num_mod number(1);
num_all number(10);
begin
num_all := NUM;
while (num_all != 0)
loop
num_mod := mod(num_all, 2);
num_all := trunc(num_all / 2);
result := num_mod || result;
end loop;
return result;
end FUNC_TO_CHAR;
right
A 1100001111
B 1101101111
--还是
right
1101101111