Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajesh GamiRank #30 · 41.5K reputationPosted Nov 15, 2022, 8:45 AM EST
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:
SELECT MID(column_name,start,length) AS some_name FROM table_name; specifying length is optional here, and start signifies start position ( starting from 1 )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 SharmaRank #104 · 20.6K reputationPosted Nov 13, 2022, 9:49 AM EST
Hi Naresh,
To know more about Aggregate and Scalar Functions in SQL, visit
Thanks!
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Oct 31, 2022, 7:26 AM EDT
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.