Give SQL Query to find the number words in a sentence ?
ex: 'ram charan singh' then ans:3
Answer:select length(trim('ram charan singh')) - length
(replace
(trim ( 'ram charan singh'),' ','')) +1 from dual
The above query working properly when space between the
words is only one &similar
But ,If the space between the words is nonuniform.
Ex:'ram charan singh is good' ans:5
i am not getting this answer using above query.
Answer Posted / murali mohan
Try This in 10g
SELECT length(REGEXP_REPLACE('ram charan
singh is good',
'( ){2,}', ' ')) - length(replace (trim ( 'ram
charan singh is good'),' ','')) +1
AS RX_REPLACE
FROM dual;
Regards,
Murali
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Explain alias?
How to drop a stored function?
What are the restrictions in a oracle read only transaction?
What are the various constraints used in oracle?
How many memory layers are in the oracle shared pool?
How translate command is different from replace?
What is bulk load in oracle?
State some uses of redo log files?
How would you begin to troubleshoot an ORA-3113 error?
Can select statements be used on views in oracle?
What is the exact use of Collections?
Explain a segment?
How to list all indexes in your schema?
How to change program global area (pga) in oracle?
What is a read write transaction in oracle?