Merk
Tilgang til denne siden krever autorisasjon. Du kan prøve å logge på eller endre kataloger.
Tilgang til denne siden krever autorisasjon. Du kan prøve å endre kataloger.
Applies to:
Databricks SQL
Databricks Runtime
Returns expr bitwise signed right shifted by n bits. This function is a synonym for >> (gt gt sign) operator.
Syntax
shiftright(expr, n)
Arguments
expr: AnINTEGERorBIGINTexpression.n: AnINTEGERexpression specifying the number of bits to shift.
Returns
The result type matches expr.
When expr is negative (that is, the most significant bit is set), the result remains negative because the function preserves the most significant bit.
The effective shift distance is n modulo 32 for an INTEGER expr and modulo 64 for a BIGINT expr.
Examples
> SELECT shiftright(4, 1);
2
> SELECT shiftright(-4, 1);
-2
> SELECT shiftright(1, -1);
0
> SELECT 4 >> 1;
2
> SELECT -4 >> 1;
-2