BIT_AND()

Overview

Returns a bitwise "and" operation across a set of aggregated numbers.

USAGE

BIT_AND(number)

Argument Name

Description

number

The number to "and" into the aggregated value

DETAILS

BIT_AND() is an aggregate function that returns the bitwise "and" of a set of values.

The value is computed with 64-bit (BIGINT) precision.

A string input value is parsed into an integer, with only digits at the start of the string being significant. If there are no leading digits, it is processed as a 0 value.

A NULL input value is ignored, just as if the row didn't exist.

If no numeric values are in the input set, a 64-bit value with all bits set to 1 is returned.

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

EXAMPLES

CREATE TABLE bit_and_example (
  item VARCHAR(20),
  val INT
);
INSERT INTO bit_and_example VALUES
  ('Foo', 242),
  ('Bar', 101),
  ('Baz', 99),
  ('Foo', 113),
  ('Bar', 64),
  ('Baz', 86);
SELECT BIT_AND(val)
 FROM bit_and_example;
+--------------+
| BIT_AND(val) |
+--------------+
|           64 |
+--------------+
SELECT item, BIT_AND(val)
  FROM bit_and_example
  GROUP BY item
  ORDER BY item;
+------+--------------+
| item | BIT_AND(val) |
+------+--------------+
| Bar  |           64 |
| Baz  |           66 |
| Foo  |          112 |
+------+--------------+

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

23.09

  • Present starting in MariaDB Xpand 23.09.1.

6.1

  • Present starting in MariaDB Xpand 6.1.0.

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.1

  • Present starting in MariaDB Xpand 6.1.0.

EXTERNAL REFERENCES