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

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, SQLServer, SQLite, Vertica, YugabyteDB

(16 >> 4)

ClickHouse

bitShiftRight(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 */
Generated with jOOQ 3.20. Translate your own SQL on our website

Feedback

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

The jOOQ Logo