RE: Find the position of a character in a string

RE: Find the position of a character in a string

 

  

WITH t(number, pos) AS
( VALUES ( 0, 0 )
UNION ALL
SELECT number+1, LOCATE('@', '~[Email Address Removed] pos+1) FROM t
WHERE number < 50
) SELECT distinct pos FROM t where pos <> 0 ;



POS
-----------
5
9
17
18
19
20
21
25
33

--Rahul Singh



-----Original Message-----
From: Edwards Ed [mailto:db2udbdba-ezmlmshield-x45679882.[Email address protected]
Sent: Tuesday, September 26, 2006 11:19 PM
To: LazyDBA Discussion
Subject: RE: Find the position of a character in a string

Well, well, well!
It's Ed Edwards from DOE: DB2 UDB and Z/OS, OS/390 Glue Root #1!
hehe. Am I back? Can you hear me now? Hehe.



-----Original Message-----
From: Schleicher Jeremy D.
[mailto:db2udbdba-ezmlmshield-x37129598.[Email address protected]
Sent: Monday, September 25, 2006 3:55 PM
To: LazyDBA Discussion
Subject: FW: Find the position of a character in a string




SELECT LASTNAME,
CASE SUBSTR(lastNAME,1,1) WHEN 'A' THEN '1' END AS "POS1",
CASE SUBSTR(lastNAME,2,1) WHEN 'A' THEN '2' END AS "POS2",
CASE SUBSTR(lastNAME,3,1) WHEN 'A' THEN '3' END AS "POS3",
CASE SUBSTR(lastNAME,4,1) WHEN 'A' THEN '4' END AS "POS4",
CASE SUBSTR(lastNAME,5,1) WHEN 'A' THEN '5' END AS "POS5",
CASE SUBSTR(lastNAME,6,1) WHEN 'A' THEN '6' END AS "POS6",
CASE SUBSTR(lastNAME,7,1) WHEN 'A' THEN '7' END AS "POS7",
CASE SUBSTR(lastNAME,8,1) WHEN 'A' THEN '8' END AS "POS8",
CASE SUBSTR(lastNAME,9,1) WHEN 'A' THEN '9' END AS "POS9",
CASE SUBSTR(lastNAME,10,1) WHEN 'A' THEN '10' END AS "POS10"
FROM EMPLOYEE
WHERE LASTNAME LIKE '%A%'
ORDER BY LASTNAME
FETCH FIRST 100 ROWS ONLY;






Please take a few minutes to provide feedback on the quality of service
you received. The Department of Education values your feedback as a
customer. Commissioner John L. Winn is committed to continuously
assessing and improving the level and quality of services provided to
you by Department staff. Simply use the link below. Thank you in
advance for completing the survey.


http://data.fldoe.org/cs/default.cfm?staff=Ed.[Email address protected]
%20Mon%2025%20Sep%202006




-----Original Message-----
From: David Baker
[mailto:db2udbdba-ezmlmshield-x41083109.[Email address protected]
Sent: Monday, September 25, 2006 1:07 PM
To: LazyDBA Discussion
Subject: Find the position of a character in a string

Anyone know how to find the position of a character (or positions if
more
than one in a string?

Ex: find ';' in kji;23ijij;kjifd would return 4 and 11.

Thanks!

David Baker
Taido Ryu Jujitsu
www.TaidoRyu.com
518-210-1000






---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html


---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html


---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html



DB2 & UDB email list listserv db2-l LazyDBA home page