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.
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / devraj
Select Length('ram charan singh') - length(replace('ram
charan singh', ' ','')) from dual;
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / aseem k
a is only column for table e
select a,length(regexp_replace(regexp_replace(a, '[^ ]
{1,}','1') ,'( +){1,}',''))
from e
/
it took me exactly 90 min's
| Is This Answer Correct ? | 0 Yes | 1 No |
Can we store images in oracle database?
What are the differences between date and timestamp in oracle?
What is COST-based approach to optimization ?
How to test null values?
How to make a Data Backup in oracle ? What is the procedure for creating the dump files in oracle ( any version ) ?
How to open and close an explicit cursor in oracle?
What is oracle in java?
What is flashback in Oracle?
How can we find out the duplicate values in an oracle table?
"primary key=unique+null" is equal,reson?not,reason?
What is Java Pool in Oracle?
How to synchronize 2 schema's objects?