I can’t seem to get my SQL code to work and I have gotten it to accept the EventRequest.eventno statement however there is another error stating that ‘the query does not include specified expression ‘dateheld’ as part of an aggregate function.’ I currently just started coding on Access SQL query and I know that since it is a date I cannot COUNT or SUM it and its a SELECT which mean that when its in Design View it would show the dateheld and I have checked several times to see if I wrote it right which I am. I just cannot see what I am doing wrong for I am working with 2 tables and the dateheld only shows within the EventRequest table.
SELECT EventRequest.eventno, COUNT(EventPlan.planno) AS NumEvents, EventRequest.dateheld FROM EventRequest, EventPlan WHERE EventRequest.eventno = EventPlan.eventno AND workdate BETWEEN #01-Dec-2013# AND #31-Dec-2013# Group BY EventRequest.eventno;
Advertisement
Answer
Do it this way:
We missed EventRequest.dateheld from the group by
SELECT EventRequest.eventno, COUNT(EventPlan.planno) AS NumEvents, EventRequest.dateheld FROM EventRequest, EventPlan WHERE EventRequest.eventno = EventPlan.eventno AND workdate BETWEEN #01-Dec-2013# AND #31-Dec-2013# Group BY EventRequest.eventno, EventRequest.dateheld;