Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Select Sum in SQL

Select Sum in SQL

SELECT SUM() in SQL

The SUM() function is an aggregate function that calculates the total sum of a numeric column.


Syntax:

SELECT SUM(column_name) FROM table_name WHERE condition;

Examples:

Get total salary from employees table:

SELECT SUM(salary) AS total_salary FROM employees;

Get total sales amount for a specific department:

SELECT SUM(sales_amount) AS department_salesFROM salesWHERE department = 'Electronics';

Use with GROUP BY to get sum per group:

SELECT department, SUM(salary) AS total_salaryFROM employeesGROUP BY department;

Notes:

  • Only works on numeric columns.

  • Returns NULL if no rows match the condition.

  • Often used in reports and summaries.


Want me to show you how to combine SUM() with other aggregate functions or filters?

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql