What are aggregate and scalar functions?
Loading
What are aggregate and scalar functions?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajesh GamiPosted Nov 15, 2022, 1:45 PM
For doing operations on data SQL has many built-in functions, they are categorized in two categories and further sub-categorized in different seven functions under each category. The categories are:
These functions are used to do operations from the values of the column and a single value is returned.
These functions are based on user input, these too returns single value.
Students-Table
Aggregate Functions
AVG(): It returns the average value after calculating from values in a numeric column.
Syntax:
Queries:
Output:
Output:
COUNT(): It is used to count the number of rows returned in a SELECT statement. It can’t be used in MS ACCESS.
Syntax:
Queries:
Output:
Output:
FIRST(): The FIRST() function returns the first value of the selected column.
Syntax:
Queries:
Output:
Output:
LAST(): The LAST() function returns the last value of the selected column. It can be used only in MS ACCESS.
Syntax:
Queries:
Output:
Output:
MAX(): The MAX() function returns the maximum value of the selected column.
Syntax:
Queries:
Output:
Output:
MIN(): The MIN() function returns the minimum value of the selected column.
Syntax:
Queries:
Output:
Output:
SUM(): The SUM() function returns the sum of all the values of the selected column.
Syntax:
Queries:
Output:
Output:
Scalar Functions
UCASE(): It converts the value of a field to uppercase.
Syntax:
Queries:
Output:
LCASE(): It converts the value of a field to lowercase.
Syntax:
Queries:
Output:
MID(): The MID() function extracts texts from the text field.
Syntax:
Queries:
Output:
LEN(): The LEN() function returns the length of the value in a text field.
Syntax:
Queries:
Output:
ROUND(): The ROUND() function is used to round a numeric field to the number of decimals specified.NOTE: Many database systems have adopted the IEEE 754 standard for arithmetic operations, which says that when any numeric .5 is rounded it results to the nearest even integer i.e, 5.5 and 6.5 both gets rounded off to 6.
Syntax:
Queries:
Output:
NOW(): The NOW() function returns the current system date and time.
Syntax:
Queries:
Output:
FORMAT(): The FORMAT() function is used to format how a field is to be displayed.
Syntax:
Queries:
Output:
Onkar SharmaPosted Nov 13, 2022, 2:49 PM
Hi Naresh,
To know more about Aggregate and Scalar Functions in SQL, visit
Thanks!
Rajanikant HawaldarPosted Oct 31, 2022, 11:26 AM
Aggregate functions operate against a collection of values and return a single summarizing value. Scalar functions return a single value based on scalar input arguments. Some scalar functions, such as CURRENT_TIME, do not require any arguments.
For doing operations on data SQL has many built-in functions, they are categorized in two categories and further sub-categorized in different seven functions under each category. The categories are:
Aggregate functions:These functions are used to do operations from the values of the column and a single value is returned.
Scalar functions:These functions are based on user input, these too returns single value.