Re: Oracle Query [message #373938] |
Thu, 17 May 2001 10:51 |
Sundar Venkatasubramaniam
Messages: 26 Registered: May 2001
|
Junior Member |
|
|
assume that col1 is abcdef and col2 is cd then if you want know what percent of col1 is col2 then try
select decode(instr(col1,col2),0,0,length(col2))/length(col1)*100 from your table;
note i always assume length of col1 is greater than col2. if you want any one may be greater and you want percentage of smaller present in greater then
select decode(sign(length(col1)-length(col2)),1,
decode(instr(col1,col2),0,0,length(col2))/length(col1)*100,
-1,decode(instr(col2,col1),0,0,length(col1))/length(col2)*100,
decode(col1,col2,100))
from your table
|
|
|