Home » RDBMS Server » Server Administration » Oracle Query
Oracle Query [message #373866] Wed, 16 May 2001 04:43 Go to next message
mani
Messages: 105
Registered: September 1999
Senior Member
can somebody suggest me a good logic to find
name percentage between two columns.
kindly Treat this as urgent.

Help would be really appreciated

Mani
Re: Oracle Query [message #373941 is a reply to message #373866] Thu, 17 May 2001 12:15 Go to previous message
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
Previous Topic: display leading zero in a numeric field
Next Topic: SQL
Goto Forum:
  


Current Time: Wed Jul 03 17:05:56 CDT 2024