HPL/SQL is included to Apache Hive since version 2.0
HPL/SQL is included to Apache Hive since version 2.0
INSTR function returns the starting position of a substring within a string.
Syntax:
INSTR(string, substring [, position [, occurrence]])
Notes:
Return Type:
INT
Example 1:
Find the first occurrence starting from the beginning:
INSTR('abc', 'b') -- Result 2
Example 2:
Find the first occurrence starting from the 3rd position:
INSTR('abcabc', 'b', 3) -- Result 5
Example 3:
Find the second occurrence starting from the 3rd position:
INSTR('abcabcabc', 'b', 3, 2) -- Result 8
Example 4:
Find the first occurrence starting from the 3rd position from the end:
INSTR('abcabcabc', 'b', -3) -- Result 5
Example 5:
Find the second occurrence starting from the 3rd position from the end:
INSTR('abcabcabc', 'b', -3, 2) -- Result 2
Compatibility: Oracle, IBM DB2 and Teradata.
Version: PL/HQL 0.3.11