1-- ORACLE substr(string, start, [, length ])
2SELECT substr('Hello World', 4, 5) FROM DUAL; -- lo Wo
3SELECT substr('Hello World', 4) FROM DUAL; -- lo World
4SELECT substr('Hello World', -3) FROM DUAL; -- rld
5SELECT substr('Hello World', -3, 2) FROM DUAL; -- rl
1/*Using SUBSTR in Oracle (Example from hackerrank.com): */
2
3/*Simple select query...*/
4SELECT DISTINCT city
5FROM station
6
7/*Using WHERE and SUBSTR to find (distinct) cities in station table that begin
8as well as end with a vowel.*/
9WHERE SUBSTR(city,1,1) IN ('A','E','I','O','U')
10 AND substr(city,-1) IN ('a','e','i','o','u');
11
12/*Parameters for SUBSTR (Substring) in order are as follows:
13String, Start, Length.*/