The function SUM is used for getting the total amount of sales of all the given stores. In case, we want to know the record of sales of all stores individually, what will we use? Here we have to do 2 important things. First of all, we will SELECT the name of a store with its whole sale. Secondly, we will check that sales are grouped by according to their stores.
The structure of this function is given below,
GROUP BY "column_name1"
It can be explained with the use of this table,
Los Angeles $1550 Jan-05-2011
San Diego $200 Jan-06-2011
San Diego $350 Jan-08-2011
Boston $750 Jan-08-2011
The syntax is given here for finding the total amount of sales of every store.
GROUP BY store_name
Los Angeles $1550
San Diego $550
In order to select many columns of a table having one or more than one calculating, the command GROUP BY is needed in SQL.