sql query to sum two columns values based on its record – How to SUM two fields within an SQL query?

sql query to sum two columns values based on its record – The SQL AGGREGATE SUM() function returns the SUM of all selected column. SQL SUM() function returns the total sum of values of a numeric column in a table.

sql query to sum two columns values based on its record

SELECT  ID, SUM(VALUE1), SUM(VALUE2)
FROM    DBTblNm
GROUP   BY ID

how to sum two columns value in sql?

sql add two values together

SELECT  ID, SUM(VALUE1 + VALUE2)
FROM    DBTblNm
GROUP   BY ID

--or simple addition

SELECT
	ID,
	(VALUE1 + VALUE2) as AddedValues
FROM DBTblNm

SUM of Multiple columns of MySQL table

SELECT id, name, class,( laravel + angularjs + vuejs) AS total
			FROM devloper_sum

Calculating Percentage of Marks

SELECT name, (( laravel + angularjs + vuejs)/(95*3) * 100) AS percentage 
 FROM `devloper_sum`

don’t Miss : SQL SELECT SUM on multiple INNER JOIN with another table

Displaying Total Mark with Percentage

SELECT id, name, class,( laravel + angularjs + vuejs) as Total,
(( laravel + angularjs + vuejs)/(95*3) * 100) AS percentage 
 FROM `devloper_sum`

I hope you get an idea about sql query to sum two columns values based on its record.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment