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 |
Difference between NO DATA FOUND and %NOTFOUND?
how to see the data (in unix) using dataset in datastage?
16. Display the order number, order line number and the shipping date. If the shipping date is null, display the string <not shipped yet>.
Differentiate between pre-select and pre-query?
What suggestions do you have to reduce the network traffic?
What are synonyms used for ?
how do u know the total no of rows in a table?
How to use subqueries in the from clause in oracle?
Does rowid change in oracle?
What is translate in oracle?
How to list all user accounts in oracle?
Explain the use of control file?