SHIFTLEFT Function Syntax | Teradata Vantage - SHIFTLEFT Function Syntax - Advanced SQL Engine - Teradata Database

SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/djk1612415574830.ditamap
dita:ditavalPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/wrg1590696035526.ditaval
dita:id
B035-1145
lifecycle
previous
Product Category
Teradata Vantageā„¢
[TD_SYSFNLIB.] SHIFTLEFT ( target_arg, num_bits_arg )

Syntax Elements

TD_SYSFNLIB.
Name of the database where the function is located.
target_arg
A numeric or variable byte expression.
num_bits_arg
An integer expression indicating the number of bit positions to shift.
IF... THEN the function...
num_bits_arg is equal to zero returns target_arg unchanged.
num_bits_arg is negative shifts the bits to the right instead of the left.
target_arg and/or num_bits_arg are NULL returns NULL.
num_bits_arg is larger than the size of target_arg returns an error.

The scope of the shift operation is bounded by the size of the target_arg expression. Specifying a shift that is outside the range of target_arg results in an SQL error.

When operating against an integer value (BYTEINT, SMALLINT, INTEGER, or BIGINT), shifting a bit into the most significant position will result in the integer becoming negative. This is because all integers in Vantage are signed integers.