next up previous contents index
Next: SG Graphics and LOCUS Up: The LOCUS Database System Previous: Entering Commands from a

Math Functions and Operators

  Calculations are expressed using the following operators and functions: [2]Because this function has an embedded comma, any expression containing this must be enclosed in double quotes.

[3]This is an aggregate function and applies to the column x.

+ Addition
- Subtraction (or unary minus)
* Multiplication
/ Division
** Exponentiation
abs(x) Absolute value of x
sqrt(x) Square root of x
exp(x) e raised to the x
log(x) Natural log of x
cos(x) Cosine of x (x in radians)
sin(x) Sin of x (x in radians)
atan(x) Arc tangent of x (in radians)

min(x,y)

Minimum of x and y
max(x,y) Maximum of x and y
asin(x) Arc sine of x (in radians)
acos(x) Arc cosine of x (in radians)
cosh(x) Hyperbolic cosine of x (x in radians)
sech(x) Hyperbolic cosecant of x (x in radians)
pi pi

int4(x)

Integer truncation of x
mod(x,y) Remainder of x/y
min(x) Minimum of x
max(x) Maximum of x
count(x) Count of x
countu(x) Count of unique x
sum(x) Sum of x
sumu(x) Sum of unique x
avg(x) Average of x
avgu(x) Average of unique x

Relational operators  are =,!=,<,<=,>,>=. These return 0 for false and 1 for true. Logical operators and and or may also be used: and is denoted by * and or is denoted by +. Relational operators  =,!=,<,<=,>,>= and logical operators and, or, and not can be used in constraints, e.g., (SHOT!=37123)AND(NE>=2.5E13). Note that there are no spaces around the ``AND''.

Note: You can simulate the use of logical expressions (i.e. if then else) by using absolute value. For example, suppose that f is e1 if y is less than one and e2 if y is greater than one. Define an expression u = (abs(y-1) /(y-1) + 1)/2 and then define f = (1-u) e1 + (u) e2.

Note: Integer ratios are truncated in expression evaluation. If you ask for 20/100 to be retrieved the result is 0; if you ask for 20./100 the result is 0.2.


next up previous contents index
Next: SG Graphics and LOCUS Up: The LOCUS Database System Previous: Entering Commands from a

Marilee Thompson
Fri Jul 11 17:05:56 EDT 1997