Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Applies to:
Databricks SQL
Databricks Runtime
Returns the substring of expr that starts at pos and is of length len. This function is a synonym for substr function.
Syntax
substring(expr, pos [, len])
substring(expr FROM pos [FOR len] ] )
Arguments
expr: AnBINARYorSTRINGexpression.pos: An integral numeric expression specifying the starting position.len: An optional integral numeric expression.
Returns
A STRING.
pos is 1 based. If pos is negative the start is determined by counting characters (or bytes for BINARY) from the end.
If len is less than 1 the result is empty.
If len is omitted the function returns on characters or bytes starting with pos.
Examples
> SELECT substring('Spark SQL', 5);
k SQL
> SELECT substring('Spark SQL', -3);
SQL
> SELECT substring('Spark SQL', 5, 1);
k
> SELECT substring('Spark SQL' FROM 5);
k SQL
> SELECT substring('Spark SQL' FROM -3);
SQL
> SELECT substring('Spark SQL' FROM 5 FOR 1);
k
> SELECT substring('Spark SQL' FROM -10 FOR 5);
Spar