Sunday, January 24, 2016

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

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
SELECT product,SUM(total) FROM sales group by product

Output






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

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

SQL SELECT GROUP BY: Display Sum of a Certain Column With Select Group By Rating: 4.5 Diposkan Oleh: Emoblazz

0 comments:

Post a Comment