Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

how to group by month using sql server

SELECT DATEPART(Year, PaymentDate) Year, DATEPART(Month, PaymentDate) Month, SUM(Amount) [TotalAmount]
FROM Payments
GROUP BY DATEPART(Year, PaymentDate), DATEPART(Month, PaymentDate)
ORDER BY Year, Month
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #group #month #sql #server
ADD COMMENT
Topic
Name
6+7 =