10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

System-defined FunctionsAggregate FunctionsAn aggregate function returns a single value based on the contents of acolumn. Aggregate functions are also called set functions. These functions canbe used in the select, insert, update, and delete SQL statements. You cannotuse aggregate functions in if or while statements. Aggregate functions can onlybe used in OpenROAD within SQL statements.The following example uses the sum aggregate function to calculate the totalof salaries for employees in department 23:select sum (employee.salary)from employeewhere employee.dept = 23;The following table lists the OpenROAD aggregate functions:Name Result Data Type Descriptioncount integer Count of occurrencessumavginteger, float, money,date (interval only)float, money, date(interval only)Column totalAverage (sum/count)The sum of the values must bewithin the range of the result datatype.max same as argument Maximum valuemin same as argument Minimum valueThe general syntax of an aggregate function is:function_name ([distinct | all] expr)where function_name denotes an aggregate function and expr denotes anyexpression that does not include an aggregate function reference (at any levelof nesting).To eliminate duplicate values, specify distinct; to retain duplicate values,specify all. (The default is all.) Distinct is not meaningful in conjunction withthe functions min and max, because these functions return single values.Nulls are ignored by the aggregate functions, with the exception of count, asdescribed in Count Function and Nulls (see page 62).Language Elements 61

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!