Neoview SQL Reference Manual (R2.3)
--- 1 row(s) selected.
• Return the average salary by department:
SELECT deptnum, AVG (salary) AS "AVERAGE SALARY"
FROM persnl.employee
WHERE deptnum < 3000
GROUP BY deptnum;
Dept/Num "AVERAGE SALARY"
-------- ---------------------
1000 52000.17
2000 50000.10
1500 41250.00
2500 37000.00
--- 4 row(s) selected.
BITAND Function
The BITAND function performs an “and” operation on corresponding bits of the two operands.
If both bits are 1, the result bit is 1. Otherwise the result bit is 0.
BITAND (expression, expression)
expression
The result datatype is a binary number. Depending on the precision of the operands, the
datatype of the result can either be an INT (32–bit integer) or a LARGEINT (64–bit integer).
If the max precision of either operand is greater than 9, LARGEINT is chosen (numbers with
precision greater than 9 are represented by LARGEINT). Otherwise, INT is chosen.
If both operands are unsigned, the result is unsigned. Otherwise, the result is signed.
Both operands are converted to the result datatype before performing the bit operation.
Usage
BITAND can be used anywhere in a SQL query where an expression could be used. This includes
SELECT lists, WHERE predicates, VALUES clauses, SET statement, and so on.
This function returns a numeric datatype and can be used in arithmetic expressions.
Numeric operands can be positive or negative numbers. All numeric datatypes are allowed with
the exceptions listed in the “Restrictions” (page 304) section.
Restrictions
The following are BITAND restrictions:
• must have 2 operands
• operands must be binary or decimal exact numerics
• operands must have scale of zero
• operands cannot be floating point numbers
• operands cannot be an extended precision numeric (the maximum precision of an extended
numeric datatype is 128)
Examples
>>select bitand(1,3) from (values(1)) x(a);
(EXPR)
--------------
1
304 SQL Functions and Expressions