Count and Sort by Month

G

Guest

I am trying to count the rows in a query and display it by Month/Year.
My counting works fine but I am having difficulty displaying per Month/Year.

This is the SQL view as designed by the Design View:
SELECT Count(GRV.[Date Received]) AS [CountOfDate Received], [Stock
File].Product, GRV.[Date Received]
FROM GRV INNER JOIN [Stock File] ON (GRV.Serial = [Stock File].[Serial
Number]) AND (GRV.[Date Received] = [Stock File].[Date Received]) AND
(GRV.[Warranty Period] = [Stock File].[Warranty Period])
GROUP BY [Stock File].Product, GRV.[Date Received]
HAVING ((([Stock File].Product) Like "*Digipos*" Or ([Stock File].Product)
Like "*Epson*"));

Please help :)
 
M

[MVP] S.Clark

Try:
SELECT Count(GRV.[Date Received]) AS [CountOfDate Received],
[Stock File].Product, Format("yymm",GRV.[Date Received])
FROM GRV
INNER JOIN [Stock File]
ON (GRV.Serial = [Stock File].[Serial Number])
AND (GRV.[Date Received] = [Stock File].[Date Received])
AND (GRV.[Warranty Period] = [Stock File].[Warranty Period])
GROUP BY [Stock File].Product, Format("yymm",GRV.[Date Received])
HAVING ((([Stock File].Product) LIKE "*Digipos*"
OR ([Stock File].Product) LIKE "*Epson*"));

In case the syntax isn't perfect, the gist is to format the date received
using the last two digits of the year, and the number for the month from the
Date Received in the GRV table.
 
M

Marshall Barton

Dunmarie said:
I am trying to count the rows in a query and display it by Month/Year.
My counting works fine but I am having difficulty displaying per Month/Year.

This is the SQL view as designed by the Design View:
SELECT Count(GRV.[Date Received]) AS [CountOfDate Received], [Stock
File].Product, GRV.[Date Received]
FROM GRV INNER JOIN [Stock File] ON (GRV.Serial = [Stock File].[Serial
Number]) AND (GRV.[Date Received] = [Stock File].[Date Received]) AND
(GRV.[Warranty Period] = [Stock File].[Warranty Period])
GROUP BY [Stock File].Product, GRV.[Date Received]
HAVING ((([Stock File].Product) Like "*Digipos*" Or ([Stock File].Product)
Like "*Epson*"));


What do you mean by "display by month year"?

Do you want the count to be over each month?
If so, use somthing like
Format(GRV.[Date Received], "yyyymm")
instead of the [Date Received] field everywhere except the
Count function.

Or do you want to see the count for each date plus have a
total count for each month?
If this is what you want then you shoul use a report that
groups my month and uses a group footer to display the month
totals.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top