Add digit before each group in a query

gojets1721

Registered User.
Local time
Today, 02:39
Joined
Jun 11, 2019
Messages
430
I have the a table full of customer complaints. The below query groups the data by Complaint Type and includes an average of the Product Cost.

Code:
SELECT TOP 10 ComplaintType, Avg([ProductCost]) AS AvgOfCost
FROM tblComplaintData
WHERE (((ReportYear)="2023"))
GROUP BY ComplaintType
ORDER BY Avg([ProductCost]) DESC;

I want to include a "1.", "2.", etc. in front of each Complaint Type. Any idea how to build that into the query?

Essentially the data looks like this right now:

ComplaintType​
AvgOfCost​
Service$223.50
Timeliness$123.41

And I want it to show as this in the query:

ComplaintType​
AvgOfCost​
1. Service$223.50
2. Timeliness$123.41
 
Just include a CompaintTypeNumber field in your table. Then sort by ComplaintTypeNumber.
 
Any idea how to build that into the query?
Save your query under a name, e.g. qryXX. You can then set up another query.
SQL:
SELECT
   DCount("*", "qryXX", "ComplaintType = '" & Q.ComplaintType & "' AND AvgOfCost > " & Str(Q.AvgOfCost)) + 1 & "." & Q.ComplaintType AS ComplaintTypeX,
   Q.AvgOfCost
FROM
   qryXX AS Q
 

Users who are viewing this thread

Back
Top Bottom