SQL Functions


SQL has many built-in functions for counting and calculation.


SQL Aggregate Functions

SQL Aggregate functions calculate values from columns and return a single value.

Useful Aggregate functions:

  • AVG() - Returns the average value
  • COUNT() - Returns the number of rows
  • FIRST() - Returns the value of the first record
  • LAST() - Returns the value of the last record
  • MAX() - Returns the maximum value
  • MIN() - Returns the minimum value
  • SUM() - Returns the sum

SQL Scalar Functions

SQL Scalar functions based on input values return a single value.

Useful Scalar functions:

  • UCASE() - Converts a field to uppercase
  • LCASE() - Converts a field to lowercase
  • MID() - Extracts characters from a text field, used in MySQL
  • SubString(field, 1, end) - Extracts characters from a text field
  • LEN() - Returns the length of a text field
  • ROUND() - Rounds a numeric field to the specified number of decimal places
  • NOW() - Returns the current system date and time
  • FORMAT() - Formats the display of a field

Tip:In the following chapters, we will discuss Aggregate and Scalar functions in detail.


Other extensions