In this step by step SQL Tutorial I will show you how to use SQL Group by clause with using Month, Year and aggregate functions. For the purpose of this tutorial I will use SQL Server 2012.
Prior knowledge: It might be easier for you to follow this tutorial if you have knowledge of Aggregate functions and Group by for more information visit SQL Group by.
We are going to show you how to use Month and Sum aggregate function with Group by this knowledge might help with questions like how to get Total sales amount for each Month . In the fallowing example I will show you how you could write the query.
Below I used Month function to get only month from ShipDate and new column is displayed as SalesMonth. In Group by I use month function with ShipDate field.
Once I have data group by month I Sum SalesAount field to get Total sales amout.
I add some filter to show only months from 2006.
Hope that helps