Hello. I need to create a total for a field in a query. Simple query. 1 table. But the problem (for me anyway) is that the field that I'm referring to is in the query twice. Once as a group by and another time as a count (to count the total times a value is in that field of the table). So when I try to create an alias for the sum of that field, how do I tell Access that I'm trying to total the count not the group by?
What got me here was that I was trying to alter a query that gave the sum of tickets closed per technician for the year. I have that functioning without the date criteria. So the query for the sum of closed tickets per tech works fine. But when I put the criteria of the closed date of being less than 365 days old from the current date, the data is there but not in a sum per tech. So I thought I would create an alias of the sum of the count.
This works but doesn't condense them into a total per tech:
SELECT TicketT.StatusID, Count(TicketT.Technician) AS CountOfTechnician, TicketT.Technician
FROM TicketT
GROUP BY TicketT.StatusID, TicketT.Technician, TicketT.TicketDate
HAVING (((TicketT.StatusID)=5) AND ((TicketT.TicketDate)>Date()-365))
ORDER BY Count(TicketT.Technician);
This condenses them in to a total per tech, but it's not restricted to tickets within a year:
SELECT TicketT.Technician, Count(TicketT.Technician) AS CountOfTechnician, TicketT.StatusID
FROM TicketT
GROUP BY TicketT.Technician, TicketT.StatusID
HAVING (((TicketT.StatusID)=5))
ORDER BY Count(TicketT.Technician) DESC;
Thanks in advance.
What got me here was that I was trying to alter a query that gave the sum of tickets closed per technician for the year. I have that functioning without the date criteria. So the query for the sum of closed tickets per tech works fine. But when I put the criteria of the closed date of being less than 365 days old from the current date, the data is there but not in a sum per tech. So I thought I would create an alias of the sum of the count.
This works but doesn't condense them into a total per tech:
SELECT TicketT.StatusID, Count(TicketT.Technician) AS CountOfTechnician, TicketT.Technician
FROM TicketT
GROUP BY TicketT.StatusID, TicketT.Technician, TicketT.TicketDate
HAVING (((TicketT.StatusID)=5) AND ((TicketT.TicketDate)>Date()-365))
ORDER BY Count(TicketT.Technician);
This condenses them in to a total per tech, but it's not restricted to tickets within a year:
SELECT TicketT.Technician, Count(TicketT.Technician) AS CountOfTechnician, TicketT.StatusID
FROM TicketT
GROUP BY TicketT.Technician, TicketT.StatusID
HAVING (((TicketT.StatusID)=5))
ORDER BY Count(TicketT.Technician) DESC;
Thanks in advance.
Last edited: