List The Minimum Account Balance
List The Minimum Account Balance
Aggregate Functions
1.16.1. SQL - Aggregate functions
Used when information you want to extract from a table has to do with the data in
the entire table taken as a set.
Aggregate functions are used in place of column names in the SELECT statement
The aggregate functions in SQL are :
SUM( ) , AVG( ) , MAX( ) , MIN( ), COUNT( )
SUM ( [ DISTINCT ] column-name / expression )
AVG ( [ DISTINCT ] column-name / expression )
MIN ( expression )
MAX ( expression )
COUNT ( [ DISTINCT ] column-name)
COUNT ( * )
1.16.2. Aggregate function MIN
Returns the smallest value that occurs in the specified column
Column need not be numeric type
Example:
List the minimum account balance.
SELECT MIN (Total_Available_Balance_in_Dollars)
FROM Customer_Transaction;
1.16.3. Aggregate function MAX
Returns the largest value that occurs in the specified column
Column need not be numeric type
Example:
List the maximum account balance.
SELECT MAX (Total_Available_Balance_in_Dollars)
FROM Customer_Transaction;
1.16.4. Aggregate function - AVG
Returns the average of all the values in the specified column
Column must be numeric data type
Example:
List the average account balance of customers.
SELECT AVG (Total_Available_Balance_in_Dollars)
FROM Customer_Transaction;
1.16.5. Aggregate function SUM
Adds up the values in the specified column
Column must be numeric data type
Value of the sum must be within the range of that data type
Example:
List the minimum and Sum of all account balance.
SELECT MIN (Total_Available_Balance_in_Dollars),
SUM (Total_Available_Balance_in_Dollars)
FROM Customer_Transaction;
1.16.6. Aggregate function COUNT
Returns the number of rows in the table
Example:
List total number of Employees.
SELECT COUNT (*) FROM Employee_Manager;