SELECT “column_name1”, SUM(“column_name2”), “column_name3″,….”column_nameZ” FROM “table_name”
GROUP BY “column_name1”, “column_name3″,….”column_nameZ”
HAVING (arithmetic function condition)
SELECT store_name, SUM(sales) FROM Store_Sales GROUP BY store_name
HAVING SUM(sales) > 1500
In the above example it displays all Stores with thier Sum of Sales which are greater than 1500.
Group by list should contain all columns in the Select List except ones which are used in Arthemitic functions like Sum.