Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Group Access data by month

Posted on 2014-11-06
3
Medium Priority
?
157 Views
Last Modified: 2015-01-04
I need to pull a query that returns information about quotes issued on a system by month. Specifically I need to see how many quotes, per month a particular rep has issued. I don't want to see a list of all the quoted dates, rather a list of all the months of the year with a number, or a zero, next to each month showing how many quotes have been issued.

Any suggestions welcomed.
0
Comment
Question by:snooflehammer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 40427384
try this

select Format([datefield], "yyyy-mmm"), count(Format([datefield], "yyyy-mmm"))
from tableName
group by  Format([datefield], "yyyy-mmm")
0
 
LVL 25

Accepted Solution

by:
chaau earned 1000 total points
ID: 40427517
The query provided by Rey will do the trick, however, if you really want to see the months with zero orders you will need to use this query:
select Format(dateSerial(ym.y, ym.m, 1), "yyyy-mm") as yyyymm, Format(dateSerial(ym.y, ym.m, 1), "yyyy-mmm") as yyyymmm, count(t.yy) as cnt
FROM
(SELECT DISTINCT Year([dateField]) as y, months.m 
FROM yourtable, 
(Select top 1 1 as m from yourtable UNION 
Select top 1 2 as m from yourtable UNION 
Select top 1 3 as m from yourtable UNION 
Select top 1 4 as m from yourtable UNION 
Select top 1 5 as m from yourtable UNION 
Select top 1 6 as m from yourtable UNION 
Select top 1 7 as m from yourtable UNION 
Select top 1 8 as m from yourtable UNION 
Select top 1 9 as m from yourtable UNION 
Select top 1 10 as m from yourtable UNION 
Select top 1 11 as m from yourtable UNION 
Select top 1 12 as m from yourtable) as months) as ym
LEFT JOIN (SELECT year([dateField]) as yy, month([dateField]) as mm FROM yourtable) as t
ON t.yy = ym.y AND t.mm = ym.m
group by  Format(dateSerial(ym.y, ym.m, 1), "yyyy-mm"), Format(dateSerial(ym.y, ym.m, 1), "yyyy-mmm")
ORDER BY 1

Open in new window

Will return something similar to this: query result
0
 
LVL 31

Expert Comment

by:hnasr
ID: 40427614
In report design:

Add Group On Expression: Year(theDate)
Add Group On Expression: Month(theDate)

In Month group header:
add a field: =Year(theDate) & " - " & Month(theDate)
add a field: =Count(theDate)
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

715 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