Solved

Access SQL Count number of items per month

Posted on 2010-11-08
4
1,025 Views
Last Modified: 2012-05-10
Hi Experts,

I am new to SQL, and would like to know if there is an easy way to do the following:

I have a table called Builds, and the fields in it are BuildDate, Hull number, ShipType.

I want to make a chart that will plot the number of HullNumbers per month.

So for example, I want to select a range of Months, Say Jan 2010, to May 2010, and get a count of the number of HullNumbers  plotted on a line chart . I guess it is like a count of the records per month.

If I have a Chart called chartB, what would the SQL query look like if it was the datasource?

I know this is a pretty simple thing, but I have not had more than a few days with SQL, and am really finding it a little esoteric.

Thanks for your help.
0
Comment
Question by:WestCoastHip
  • 3
4 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
Comment Utility
you could try something like this

SELECT COUNT(HullNumbers) AS TotalHullNumbers, Format(BuildDate,"MMM YYYY")
FROM Builds
GROUP BY Format(BuildDate,"MMM YYYY")


Create a new query in masaccess, go to sql view and paste this

Because we use COUNT we have to group all other fields
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
Since your new to SQL, it might be a good idea to use the SQL wizard.

Have a butchers here as it should hopefully help you out http://office.microsoft.com/en-us/access-help/count-data-by-using-a-query-HA010096311.aspx

0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
Now one thing I forgot to add is the build date. The date obviously has a day number in it (assuming BuildDate is stored as a date field in the database). In order to extract just the month and year we make use of the format command and specify the strings MMM (for 3 character month) and YYYY (for 4 digit year). If you highlight the Format command then hit F1, it should bring up more info plus a list of other strings to use.

If BuildDate not saved as a date but just text with no day number then remove the Format, just leave it as BuildDate (in both uses SELECT and GROUP BY)
0
 

Author Closing Comment

by:WestCoastHip
Comment Utility
Thanks for your help rocki! I appreciate your time, and the more I see the more I am learning.

Thanks again.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now