- Goal
文字列から特定の文字の間の文字を抜き出す
(例) 1234567890123 Hello 0980 982134 1adfllkjasf から1つ目の空白と 2つ目の空白の間の文字列を抜き出す。
結果として、Helloだけを抜き出す。 - Source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersINPUT 1st_BLANK 2nd_BLANK START_POSITION LENGTH GOAL 1234567890123 Hello 0980 982134 1adfllkjasf 14 20 15 5 Hello 1234567890123456 World!! 0980 982134 1adfllkjasf 17 25 18 7 World!! This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersSELECT INPUT --CHARINDEX(検索文字列,検索対象文字列,<OPTION>開始位置) , CHARINDEX(' ',INPUT) AS '1st_BLANK' --1st blank position , CHARINDEX(' ',INPUT,CHARINDEX(' ',INPUT)+1) AS '2nd_BLANK' --2nd blank position , CHARINDEX(' ',INPUT)+1 AS START_POSITION , CHARINDEX(' ',INPUT,CHARINDEX(' ',INPUT)+1) - (CHARINDEX(' ',INPUT)+1) as LENGTH -- 2nd blank - start position --SUBSTRING(文字列,開始位置,長さ) , SUBSTRING(INPUT,CHARINDEX(' ',INPUT)+1,CHARINDEX(' ',INPUT,CHARINDEX(' ',INPUT)+1) - (CHARINDEX(' ',INPUT)+1)) as GOAL FROM (VALUES('1234567890123 Hello 0980 982134 1adfllkjasf') ,('1234567890123456 World!! 0980 982134 1adfllkjasf')) as T(INPUT)
Oracle Application Express Notes | Apps development Notes | Google Cloud Platform | Python | apps test | Cool Beans | English | Books
2017/01/30
特定の文字の間の文字を切り出す - SQL
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿