0% found this document useful (0 votes)
8 views9 pages

DBMS 14 (SQL)

A function in SQL is a predefined formula that processes input arguments and returns an output. SQL functions are categorized into aggregate functions, such as Count(), Sum(), Avg(), Min(), and Max(), and non-aggregate functions, including character, number, and date functions. Each function has specific syntax for usage in SQL queries.

Uploaded by

hirshah8523
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views9 pages

DBMS 14 (SQL)

A function in SQL is a predefined formula that processes input arguments and returns an output. SQL functions are categorized into aggregate functions, such as Count(), Sum(), Avg(), Min(), and Max(), and non-aggregate functions, including character, number, and date functions. Each function has specific syntax for usage in SQL queries.

Uploaded by

hirshah8523
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

SQL FUNCTIONS

What is a function?

• A function is a predefined formula which takes


one or more arguments as input then process
the arguments and returns an output.

Input Function Output


SQL function
2. Non-
1. Aggregate Aggregate
Function
Function

Character
Count() Function

Number
Sum() Function

Date
Avg()
function

Conversion
Max()
Function

General
Min()
Function
SQL function- Aggregate Function

• Count():
– Syntax: select count([*]) from [table_name] where
[condition];

• Sum():
– Syntax: select sum([column_name]) from [table_name];

• Avg():
– Syntax: select avg([column_name]) from [table_name];
SQL function- Aggregate Function

• Min():
– Syntax: select min([column_name]) from
[table_name];

• Max():
– Syntax: select max([column_name]) from
[table_name];
SQL function- Non-Aggregate
Function
• Character Function:
– Case manipulation function:
• Upper:
–Syntax: select upper(column_name) from
table_name)
• Lower:
–Syntax: select upper(column_name) from
table_name)
SQL function- Non-Aggregate
Function
• Character Function:
– String manipulation function:
• Length:
– Syntax: select length(string)
• Concat:
– Syntax: select concat(column_name1,
column_name2) from table_name
• Substr:
– Syntax: select substr([string],[start],[end])
SQL function- Non-Aggregate
Function
• Number Function:
– Round: rounds value to specified decimal places.
• Syntax: select round(decimal value, place)

– Mod: returns remainder of division.


• Syntax: select mod(m,n)
SQL function- Non-Aggregate
Function
• Date Function:
– SYSDATE is a function that returns:
• Date
• Time
– Example:
• Select sysdate() form dual;

You might also like