Wednesday, March 21, 2012

Plz solve this Query

chiranjeevi
raveendra
sreenivasarao
koteswar
manoj
sangeetharanika

Here my query is
in the above names i want to find out the persons whoz names consist of exact 2 a's
eg output:
raveendra

assume that the names are ename and table name is emp.

Thanks in advance
Plz mail this qury to chiru_y2k@.yahoo.com

ChiranjeeviOriginally posted by chiru_y2k
chiranjeevi
raveendra
sreenivasarao
koteswar
manoj
sangeetharanika

Here my query is
in the above names i want to find out the persons whoz names consist of exact 2 a's
eg output:
raveendra

assume that the names are ename and table name is emp.

Thanks in advance
Plz mail this qury to chiru_y2k@.yahoo.com

Chiranjeevi


select * from emp where patindex('%a%',ename) =2|||Borowing a page from Brett here...

select ename
from emp
where len(replace(ename, 'a', '') + 2 = len(ename)

No comments:

Post a Comment