Expt No 3: Grouping Data, Aggregate Functions, Oracle Functions (Mathematical, Character Functions)
Expt No 3: Grouping Data, Aggregate Functions, Oracle Functions (Mathematical, Character Functions)
Expt No 3: Grouping Data, Aggregate Functions, Oracle Functions (Mathematical, Character Functions)
Name
Theory :
3.1 Aggregate Functions
Aggregate functions are used to compute against a "returned column of numeric data" from your SELECT
statement. They basically summarize the results of a particular column of selected data.
3.1.1 The MIN() Function: The MIN() function returns the smallest value of the selected column.
SELECT MIN(column_name) FROM table_name;
3.1.2 The MAX() Function: The MAX() function returns the largest value of the selected column.
SELECT MAX(column_name) FROM table_name;
3.1.3The SUM() Function: The SUM() function returns the total sum of a numeric column.
SELECT SUM(column_name) FROM table_name;
3.1.4 The AVG() Function: The AVG() function returns the average value of a numeric column.
SELECT AVG(column_name) FROM table_name;
3.1.5 The COUNT() Function: The COUNT() function returns the number of rows that matches a
specified criteria.
The COUNT(column_name) function returns the number of values (NULL values will not be
counted) of the specified column:
SELECT COUNT(column_name) FROM table_name;
3.4Trigonometric Functions
Function Description
sin() Returns sine.
TRIM Remove the longest string that contains TRIM(‘ ABC ‘) ‘ABC’
specified characters from the left, right or
both of the input string
The PostgreSQL LIKE operator is used to match text values against a pattern using wildcards. If the
search expression can be matched to the pattern expression, the LIKE operator will return true, which is
1.
There are two wildcards used in conjunction with the LIKE operator −
The percent sign represents zero, one, or multiple numbers or characters. The underscore represents a
single number or character. These symbols can be used in combinations.
If either of these two signs is not used in conjunction with the LIKE clause, then the LIKE acts like the
equals operator.
Syntax
The HAVING clause was added to SQL because the WHERE keyword could not be used with
aggregate functions.
FROM table_name
GROUP BY column_name
The ORDER BY keyword is used to sort the result-set by one or more columns.
The ORDER BY keyword sorts the records in ascending order by default. To sort the records in
FROM table_name