RE: Write an sql to....

2 views
Skip to first unread message

Pramod Jamadagni

unread,
Oct 5, 2012, 5:34:35 AM10/5/12
to ranjan...@thomsonreuters.com, mus...@planwell.com, balachandra...@genpact.com, dwhte...@googlegroups.com

Anybody else tried?

Ranjan bhai very good. you are genius…

My way is little generic…. So that is can be used for querying in the table as well.

 

with t(Indx,Char,Word)

as

(

select 1 Indx,cast(LEFT (Emp,1) as varchar(50)) Char,Emp Word from (select 'Employee' Emp) a

union all

select Indx + 1 I, cast(Right(LEFT(Word,Indx+1),1) as varchar(50)) Char,Word from t where LEN(Word) > Indx

)select * from t where Char = 'E';

 

 

From: ranjan...@thomsonreuters.com [mailto:ranjan...@thomsonreuters.com]
Sent: 05 October 2012 02:56
To: Pramod Jamadagni; mus...@planwell.com; balachandra...@genpact.com
Subject: RE: Write an sql to....

 

 

with cte(i) as

(

Select i=CHARINDEX ('E','Employee')

union all

Select i=CHARINDEX ('E','Employee',i+1) from cte where i<>0

)

select * from cte where i>0

 

From: Pramod Jamadagni [mailto:Pramod.J...@Indecomm.net]
Sent: Friday, October 05, 2012 12:36 PM
To: mus...@planwell.com; Kalita, Ranjan (Financial&Risk); balachandra...@genpact.com
Subject: Write an sql to....

 

Guys,

Can someone send me a query to know the position of the letter say “E” in the word “Employee” which would be 1st,7th,8th.

 

Thanks,

PRamod.

ranjan...@thomsonreuters.com

unread,
Oct 5, 2012, 5:42:24 AM10/5/12
to Pramod.J...@indecomm.net, mus...@planwell.com, balachandra...@genpact.com, dwhte...@googlegroups.com

Hum kaha genius hai woh to aap haiJ

Pramod Jamadagni

unread,
Oct 5, 2012, 5:46:57 AM10/5/12
to ranjan...@thomsonreuters.com, mus...@planwell.com, balachandra...@genpact.com, dwhte...@googlegroups.com

Jokes apart Mr. Ranjan

 

Let me know if there is any other approach. “Jeevo bheda gaNah” mean everybody think differently in this world J.

Reply all
Reply to author
Forward
0 new messages