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



Give SQL Query to find the number words in a sentence ? ex: 'ram charan singh' then ans:3..

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

Give SQL Query to find the number words in a sentence ? ex: 'ram charan singh' then ans:3..

Answer / devraj

Select Length('ram charan singh') - length(replace('ram
charan singh', ' ','')) from dual;

Is This Answer Correct ?    1 Yes 1 No

Give SQL Query to find the number words in a sentence ? ex: 'ram charan singh' then ans:3..

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

Post New Answer

More Oracle General Interview Questions

What language does oracle use?

0 Answers  


What are the Limitations of a CHECK Constraint ?

5 Answers  


What are internal user account in oracle?

0 Answers  


What is Index Cluster ?

2 Answers  


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.

3 Answers   Wipro,






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

2 Answers  


What is use of oracle?

2 Answers   Satyam,


How to drop an existing table in oracle?

0 Answers  


What is a public synonym?

1 Answers  


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

0 Answers   Wipro,


How to fetch the row which has the max value for a column?

0 Answers  


how do get database name at sql prompt?

3 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)