SQL > SQL Functions

Since we have started dealing with numbers, the next natural question to ask is if it is possible to do math on those numbers, such as summing them up or taking their average. The answer is yes! SQL has several arithematic functions, and they are:

SQL FunctionDescription
 AVG Average of the column.
 COUNT Number of records.
 MAX Maximum of the column.
 MIN Minimum of the column.
 SUM Sum of the column.
 ROUND Round a number to s specified precision.

The syntax for using functions is,

SELECT "function type" ("column_name")
FROM "table_name";

Examples of how these functions are used are presented individually in the next few pages.

In addition to using functions, it is also possible to use SQL to perform simple tasks such as addition (+) and subtraction (-). For character-type data, there are also several string functions available, such as concatenation, trim, and substring functions. Different RDBMS vendors have different string functions implementations, and it is best to consult the references for your RDBMS to see how these functions are used.

Next: SQL Average

This page was last updated on June 19, 2023.

Copyright © 2024   1keydata.com   All Rights Reserved     Privacy Policy     About   Contact