THE WORLD'S LARGEST WEB DEVELOPER SITE

SQL Functions


SQL has many built-in functions for performing calculations on data.


SQL Aggregate Functions

SQL aggregate functions return a single value, calculated from values in a column.

Function Description
AVG() Returns the average value
COUNT() Returns the number of rows
FIRST() Returns the first value
LAST() Returns the last value
MAX() Returns the largest value
MIN() Returns the smallest value
ROUND() Rounds a numeric field to the number of decimals specified
SUM() Returns the sum

SQL String Functions

Function Description
CHARINDEX Searches an expression in a string expression and returns its starting position if found
CONCAT()  
LEFT()  
LEN() / LENGTH() Returns the length of the value in a text field
LOWER() / LCASE() Converts character data to lower case
LTRIM()  
SUBSTRING() / MID() Extract characters from a text field
PATINDEX()  
REPLACE()  
RIGHT()  
RTRIM()  
UPPER() / UCASE() Converts character data to upper case