Available in versions: Dev (3.19) | Latest (3.18) | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10 | 3.9

SHR

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The SR() function produces the bitwise shift right operation.

SELECT shr(16, 4);
create.select(shr(16, 4)).fetch();

The result being

+-----+
| shr |
+-----+
|   1 |
+-----+

Dialect support

This example using jOOQ:

shr(16, 4)

Translates to the following dialect specific expressions:

-- ASE, HSQLDB, SQLDATAWAREHOUSE, SYBASE
(16 / CAST(power(2, 4) AS int))

-- AURORA_MYSQL, AURORA_POSTGRES, BIGQUERY, COCKROACHDB, DUCKDB, MARIADB, MEMSQL, MYSQL, POSTGRES, REDSHIFT, SQLITE, 
-- SQLSERVER, VERTICA, YUGABYTEDB
(16 >> 4)

-- DB2, INFORMIX
(16 / CAST(power(2, 4) AS integer))

-- EXASOL
bit_rshift(16, 4)

-- FIREBIRD
bin_shr(16, 4)

-- H2
rshift(16, 4)

-- ORACLE
(16 / CAST(power(2, 4) AS number(10)))

-- SNOWFLAKE
bitshiftright(16, 4)

-- TERADATA
shiftright(16, 4)

-- TRINO
bitwise_right_shift(16, 4)

-- ACCESS, DERBY, HANA
/* UNSUPPORTED */

(These are currently generated with jOOQ 3.19, see #10141), or translate your own on our website

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo