Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
SQL SELECT SUM

SQL SELECT SUM: Understanding the SUM() Function in SQL

Posted on January 30, 2025January 30, 2025 By Rishabh saini No Comments on SQL SELECT SUM: Understanding the SUM() Function in SQL

SQL SELECT SUM

The SQL SELECT SUM() function is a strong aggregate function that returns the total sum of a numeric column in a database. It is widely used in data analysis and reporting to get the total value of an expression across multiple records.

Complete Python Course with Advance topics:-Click Here
SQL Tutorial :-Click Here

SQL SUM() Syntax

SELECT SUM(expression)  
FROM table_name  
WHERE conditions;  

  • expression: This is the numeric field or formula that needs to be summed.
  • table_name: The name of the table from which data is retrieved.
  • conditions: (Optional) Specifies which records should be included in the sum calculation.

Example 1: SQL SUM with a Single Column

Let’s consider an employees table with the following data:

IDEMPLOYEE_NAMESALARY
1RAHUL SHARMA45000
2ANANYA SINGH28000
3VIKRAM PATEL39000
4MEGHA AGRAWAL23000

Query:

If we want to find the total salary of all employees earning more than 25,000, we can use:

SELECT SUM(salary) AS "Total Salary"  
FROM employees  
WHERE salary > 25000;  

Result:

Total Salary: 112,000

This query returns the total salary of employees who earn more than 25,000 per month.

Example 2: SQL SUM with DISTINCT Values

We can use the DISTINCT keyword to sum only unique salary values:

SELECT SUM(DISTINCT salary) AS "Total Salary"  
FROM employees  
WHERE salary > 25000;  

This ensures that duplicate salaries are not counted more than once.

Example 3: SQL SUM with GROUP BY

The GROUP BY statement allows us to calculate the total sales per department.

Consider the following sales_data table:

IDDEPARTMENTDATEDAILY_SALES
1IT2023-07-10500
2HR2023-07-10200
3IT2023-07-11600
4HR2023-07-11300
5FINANCE2023-07-10400

Query:

SELECT department, SUM(daily_sales) AS "Total Sales"  
FROM sales_data  
GROUP BY department;  

Result:

DEPARTMENTTOTAL SALES
IT1100
HR500
FINANCE400

This query groups the sales data by department and calculates the total sales per department.

Download New Real Time Projects :-Click here
Complete Advance AI topics:- CLICK HERE

Conclusion

The SQL SUM() function is a crucial tool for performing aggregate calculations in databases. Whether you are summing individual fields, working with distinct values, or using GROUP BY for detailed reports, SUM() simplifies data analysis effectively.

For more SQL insights and tutorials, stay connected with UpdateGadh!


sql sum SELECT multiple columns
sql sum SELECT group by
sql sum SELECT two columns
sql sum SELECT with condition
sql average group by
sql sum SELECT multiple rows
sql sum SELECT if
sql sum SELECT two columns from same table
sql join
select distinct
sql select sum multiple rows
sql select sum example
sql select sum w3schools

Post Views: 659
SQL Tutorial Tags:aggregate functions, becoming a data scientist, becomingads.com, columns sum, Data Science, data scientist, how to sum a column in sql, postgresql aggregation, sql aggregation, sql count, sql get sum, sql get sum from query, sql get sum in table, sql max, sql min, sql row count as column, sql sum, sql sum column, sql sum group by, sql sum of column, sql sum of table, sql sum query, sql sum vlaue, sum column sql, sum of column sql

Post navigation

Previous Post: What is an Object in Python?
Next Post: E-Commerce Website in Django with Source Code – Paid Project

More Related Articles

SQL DELETE JOIN SQL DELETE JOIN: A Comprehensive Guide SQL Tutorial
SQL WHERE Clause SQL WHERE Clause in SQL DML Statements SQL Tutorial
SQL ORDER BY Clause SQL ORDER BY Clause: Sorting Data in a Structured Manner SQL Tutorial

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may also like

  1. Understanding the SQL DELETE Statement and Its Variants
  2. SQL SELECT TOP Clause: A Comprehensive Guide
  3. SQL WITH Clause
  4. SQL UPDATE with JOIN
  5. Understanding SQL CROSS JOIN with Examples
  6. IN vs EXISTS in SQL: A Complete Guide

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. Flipkart Clone using PHP And MYSQL Free Source Code
  5. News Portal Project in PHP and MySql Free Source Code
  6. User Login & Registration System Using PHP and MySQL Free Code
  7. Top 10 Final Year Project Ideas in Python
  8. Blog Site In PHP And MYSQL With Source Code || Best Project
  9. Online Bike Rental Management System Using PHP and MySQL
  10. E learning Website in php with Free source code
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Agentic RAG AI System Using Python – Complete Final Year Project Guide
  • AI-Powered Online Examination System with Face Detection Using PHP & MySQL
  • Real-Time Medical Queue & Appointment System with Django
  • Online Examination System in PHP with Source Code
  • AI Chatbot for College and Hospital

Most Viewed Posts

  • Top Large Language Models in 2025 (8,632)
  • Online Shopping System using PHP, MySQL with Free Source Code (5,250)
  • login form in php and mysql , Step-by-Step with Free Source Code (4,913)

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme