PostgreSQL AGGREGATE functions
What is an aggregate function?
An aggregate function produced a single result for an entire group or table.
Aggregate functions are used to produce summarized results. They operate on sets of rows. They return results based on groups of rows. By default, all rows in a table are treated as one group. The GROUP BY clause of the select statement is used to divide rows into smaller groups.
List of aggregate functions
Name | Description |
---|---|
COUNT | This function returns the number or rows or non NULL values for a column |
SUM | This function returns the sum of a selected column. |
MAX | This function returns the largest value of a specific column. |
MIN | This function returns the smallest value of a specific column. |
AVG | This function returns the average value for a specific column. |
Syntax
aggregate_name (expression [,...] [ order_by_clause] )
OR
aggregate_name (ALL expression [,...] [ order_by_clause] )
OR
aggregate_name (DISTINCT expression [,...] [ order_by_clause] )
OR
aggregate_name (* )
Parameters
Name | Description |
---|---|
aggregate_name | Name of the aggregate function. |
expression | Expression is a value or value of the column which itself does not contain any aggregate expression. |
order_by_clause | The order_by_clause is optional which arranged the result in an order. |
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises