Infolinks

Breaking

Adsense

Sunday, January 24, 2016

SQL SELECT GROUP BY: Display Sum of a Certain Column With Select Group By

Functions are keywords in SQL used to manipulate values in database for output purposes. A function is a command normally used together with a column name that processes the data to produce an output. SQL contains several types of functions. SQL Aggregate functions can perform useful functions such as COUNT, SUM, AVG, MAX, MIN.

On my previous post, we used the SUM function to calculate the TotalSales in a store. What if we want to display the TotalSales by PRODUCT? Below is the SALES table that we will used in our query.
SALES













Query Group By

SELECT product,SUM(total) FROM sales group by product

Output Group By









First, the query will group all the same products and calculate the sum of the total column.

Feel free to post a comment below if you have questions in mind. Good day and God bless! ^_^

SQL SELECT GROUP BY: Display Sum of a Certain Column With Select Group By

No comments:

Post a Comment

Adbox