find character occurance [message #205708] |
Mon, 27 November 2006 03:30 |
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 |
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 #205746 is a reply to message #205740] |
Mon, 27 November 2006 05:32 |
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.
|
|
|