position
功能
適用于: Databricks SQL Databricks Runtime
傳回位置 之後 pos
第一次出現 substr
str
的位置。 此函式與 尋找函式同義。
語法
position(substr, str [, pos] )
position(subtr IN str)
參數
substr
:STRING 運算式。str
:STRING 運算式。pos
:INTEGER 運算式。
返回
整數。
指定的 pos
和 傳回值為 1 起始。
如果 pos
省略 , substr
則會從 的 str
開頭搜尋 。
如果 pos
小於 1,則結果為 0。
例子
> SELECT position('bar', 'abcbarbar');
4
> SELECT position('bar', 'abcbarbar', 5);
7
> SELECT position('bar' IN 'abcbarbar');
4