Link to home
Create AccountLog in
Avatar of WestCoastHip
WestCoastHip

asked on

Access SQL Count number of items per month

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.
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
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

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)
Avatar of WestCoastHip
WestCoastHip

ASKER

Thanks for your help rocki! I appreciate your time, and the more I see the more I am learning.

Thanks again.