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 |
What language does oracle use?
What are the Limitations of a CHECK Constraint ?
What are internal user account in oracle?
What is Index Cluster ?
10. Display the client number, order date and shipping date for all orders where the shipping date is between three and six months after the order date.
Create table Employee ( Employee_Id varchar2(8) Constraint emp_id_pk primary key, FirstName varchar2(50), LastName varchar2(50), DeptID Number(5) Constraint dept_id_fk Foreign Key(DeptId) References Department(DeptId) ) Error I am getting: Constraint specification are not allowed here
What is use of oracle?
How to drop an existing table in oracle?
What is a public synonym?
22. Display the order number, number of lines in the order, total number of items and total value for all orders that have a total value greater than $100
How to fetch the row which has the max value for a column?
how do get database name at sql prompt?