Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.0 » SQL Anywhere Server - SQL Reference » Using SQL » SQL functions » Alphabetical list of functions

 

BIT_XOR function [Aggregate]

Takes n bit arrays and returns a bitwise exclusive OR-ing of its arguments using the following logic: for each bit compared, if there are an odd number of arguments with set bits (odd parity), return 1; otherwise, return 0.

Syntax
BIT_XOR( bit-expression )
Parameters
  • bit-expression   The expression for which the value is to be determined. This is commonly a column name.

See also
Standards and compatibility
  • SQL/2003   Vendor extension.

Example

Suppose you have the following table, t, containing a single column, a, which is a VARBIT data type.

a
0001
0111
0100
0011

You want to know the XOR value for the column. You enter the following SELECT statement, which returns 0001:

SELECT BIT_XOR( a ) FROM t;

This result is determined as follows:

  1. A bitwise exclusive OR (XOR) is performed between row 1 (0001) and row 2 (0111), resulting in 0110.
  2. A bitwise XOR is performed between the result from the previous comparison (0110) and row 3 (0100), resulting in 0010.
  3. A bitwise XOR is performed between the result from the previous comparison (0010) and row 4 (0011), resulting in 0001.