Home » SQL & PL/SQL » SQL & PL/SQL » find character occurance
find character occurance [message #205708] Mon, 27 November 2006 03:30 Go to next message
mehulmb
Messages: 25
Registered: May 2006
Location: Pune
Junior Member

Dear Friend,
I need to know how many same character occure in my table column. e.g.

my table name is : abc
column name : name
rows inserted in table : 'hello'
'how are you....?'
'abcdgaacgddddagh'

now i want to get same character occurance in column data with only one query..i dont want to use cursor or loop. i wanna do it with only one single or one query with sub-query.

thanks....
Re: find character occurance [message #205711 is a reply to message #205708] Mon, 27 November 2006 03:47 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Am I right in thinking that you want to know how many times a single character occurs in a single column across all the rows in the table?

If so, you can do this to find how many times the character 'A' occurs:
(untested)
SELECT sum(length(column_name) - length(replace(column_name,'A',null)))
FROM table_name;
Re: find character occurance [message #205740 is a reply to message #205711] Mon, 27 November 2006 05:11 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
similar thread

MHE
Re: find character occurance [message #205746 is a reply to message #205740] Mon, 27 November 2006 05:32 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
It's unreasonable to expect the OP to have found that, because that deals with getting the number of chrs in a single string, and his problem is soooooooo different.
Cool
Previous Topic: what is the difference between SQL ,PL/SQL , ORACLE ? i want with examples
Next Topic: Exception Handling_Unknown Error
Goto Forum:
  


Current Time: Fri Apr 26 17:32:15 CDT 2024