MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL sum() Function

The MySQL sum() function returns the total summed value of a numeric field. It is used when you need to addition the numeric fields value.

MySQL SUM FUNCTION Syntax

To count or calculate number of rows in a table, use the following syntax:

Syntax

SELECT SUM(col1) 
FROM tablename
WHERE condition;

Parameters:

tablename: The table name from which you want to fetch records.

col1: The column or field name that will be summed. It will summed the numeric field values.

MySQL SUM FUNCTION example

The following MySQL, adding the numeric field "workingHours" in the "tblCustomerLoan" table:

Example

SELECT SUM(workingHours) AS TotalHover FROM tblCustomerLoan;

Note:

In the above example, we are adding "workingHours" numeric field value in tblCustomerLoan" table.

You can use MySQL Command Line Client to summed numeric field value in the specified table. It will look like this: