Newsgroups: comp.databases.oracle.misc
From: "Charles Hooper" <hooperc2...@yahoo.com>
Date: 23 Jan 2007 10:42:22 -0800
Local: Tues, Jan 23 2007 1:42 pm
Subject: Re: character count in a string
Charles Hooper wrote: gazzag suggested SUBSTR, looks like that will work also: > DA Morgan wrote: > > Charles Hooper wrote: > > > Eitan M wrote: > > >> Hello, > > >> how can I get a specific character count in a string > > >> ( > > >> i.e : string is 56222, and I am looking for '2' occurance > > >> when i do : > > >> select charcount('56222') should return : 3 > > >> ) > > >> Thanks :) > > > INSTR is all that you need. See: > > > Charles Hooper > > Given the quality of your responses I am going to have to ask ... how. > > SELECT LENGTH(TRANSLATE('56222', '2013456789', '2')) FROM dual; > > Though I can see numerous creative possibilities using regular > Sorry, I misread the question and do not have an answer. I thought > Ignore this: > SUM(SIGN(INSTR('562225622256222','2',1,ROWNUM))) > Charles Hooper SELECT SUM(DECODE(SUBSTR('562225622256222',ROWNUM,1),'2',1,0)) FROM DUAL CONNECT BY LEVEL<255; SUM(DECODE(SUBSTR('562225622256222',ROWNUM,1),'2',1,0)) Charles Hooper You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||