Use of Aggregate Functions

Use of Aggregate Functions Use of Aggregate Functions

SQL Aggregate Function - SQL aggregation function is used to perform calculations on multiple rows of a single column of a table. It returns a single value and is also used to summarize the data.
Types of Aggregate Function:
  1. Count Function - COUNT function is used to count the number of rows in a database table. It can work on both numeric and non-numeric data types. COUNT function uses COUNT(*) that returns the count of all the rows in a specified table. COUNT(*) considers duplicate and Null.
  2. Sum Function - Sum function is used to calculate the sum of all selected columns. It works on numeric fields only.
  3. AVG Function - The AVG function is used to calculate the average value of the numeric type. AVG function returns the average of all non-Null values.
  4. MAX Function - MAX function is used to find the maximum value of a certain column. This function determines the largest value of all selected values of a column.
  5. MIN Function - MIN function is used to find the minimum value of a certain column. This function determines the smallest value of all selected values of a column.
QUERY*
    create table Product(Product_name varchar(10), Company_name varchar(15), Quantity number(5), cost number(10));
    desc Products;
  
OUTPUT
Fig... 5.1

QUERY*
    insert into Product values('Milk', 'verka', 10, 100);
    insert into Product values('butter', 'amul', 15, 90);
    insert into Product values('curd', 'verka', 19, 50);
    insert into Product values('coffee', 'nestle', 45, 55);
    insert into Product values('lassi', 'amul', 10, 45);
    insert into Product values('Milk', 'amul', 6, 100);
    insert into Product values('butter', 'verka', 45, 77);
    insert into Product values('candies', 'nestle', 10, 100);
    insert into Product values('chocolate', 'nestle', 20, 110);
    insert into Product values('lassi', 'verka', 33, 75);
    Select count(*) from Product;
  
OUTPUT
Fig... 5.2
QUERY*
    select count(*) from Product where quantity < 20;
  
OUTPUT
Fig... 5.3

Comments

Popular posts from this blog

SQL IS NOT NULL.

Database Management System

SQL BETWEEN Operator Example.