Functions can come in a couple of flavors. There are table-valued functions, in which you can pass in one or a group of values and get a table of values in return. There are also scalar-valued functions, in which you pass in one or a group of values and get a single return value.
Aggregate functions are functions that operate on a group of values to return a single value. There are several built-in functions of SQL Server that perform aggregation: COUNT(), MIN(), MAX(), SUM(), and others. All of these, with the exception of COUNT(), ignore NULL values. You may also create your own user-defined ...