Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I summarize by month in a view

Status
Not open for further replies.

stocktondesigns

Technical User
Aug 31, 2003
16
US
I have a View query for the number of product registrations in my table. I have got my View query to SUM and give me a grand total, but I would like the view to show total for each month:

Date Total
Jan 20
Feb 30
Mar 22

In Access, I can use the 'Month: Format([Date],[mmm])' to format a date field, but in SQL ADP I am unable to use this in the View designer. Is there a way to generate the results I describe in a view?
 
A lot of the functions have the same name in sql server for example datepart. Convert is similiar to Format.

Convert(varchar(10),yourdate,101)
Convert is similiar to the format function in access. The 3rd parameter is the Style which you will need to look up under help in sql server to get the format you want

DATEPART(mm, date)

Select * datepart(mm, yourdate) as mymonth from yourtable
group by datepart(mm, yourdate)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top