Hello! I hope this hasn't been covered elsewhere, I searched the forums - but ya never know...
Background: I have a database which tracks requests from different departments. The requests are assigned sequential numbers (MOC#) regardless of the department it comes from.
I created a report which groups the requests by department, sorts ascending by MOC# and counts the number of requests per department using =Count(*).
Problem: I would like to sort that count so that the department with the smallest number of requests is at the top of the report and I can't figure this out! :banghead:
I created a second query which groups the departments, shows the count, and sorts it ascending. I joined that query with the original query that contains all of my data. Initially it works fine and shows me exactly what I want, but when I try to use it as my report's record source, I get a "circular reference" error. I'm just starting (attempting) to learn SQL so hopefully it's something simple?
SELECT qryMOCDepts.Dept, qryMOCDepts.DeptCount, [qryOpenMOCs].[MOC Number], [qryOpenMOCs].Status, [Open MOCs].Department, [qryOpenMOCs].[Date Issued], [qryOpenMOCs].Description, [qryOpenMOCs].Owner, [qryOpenMOCs].Comments
FROM (Departments INNER JOIN [qryOpenMOCs] ON Departments.[ID] = [qryOpenMOCs].[Department]) INNER JOIN qryMOCDepts ON Departments.[ID] = qryMOCDepts.[Dept];
Also, if there's a different way to do this, I'm open to suggestions!
Hopefully this makes sense... thank you in advance for any help.
Alecia
Background: I have a database which tracks requests from different departments. The requests are assigned sequential numbers (MOC#) regardless of the department it comes from.
I created a report which groups the requests by department, sorts ascending by MOC# and counts the number of requests per department using =Count(*).
Problem: I would like to sort that count so that the department with the smallest number of requests is at the top of the report and I can't figure this out! :banghead:
I created a second query which groups the departments, shows the count, and sorts it ascending. I joined that query with the original query that contains all of my data. Initially it works fine and shows me exactly what I want, but when I try to use it as my report's record source, I get a "circular reference" error. I'm just starting (attempting) to learn SQL so hopefully it's something simple?
SELECT qryMOCDepts.Dept, qryMOCDepts.DeptCount, [qryOpenMOCs].[MOC Number], [qryOpenMOCs].Status, [Open MOCs].Department, [qryOpenMOCs].[Date Issued], [qryOpenMOCs].Description, [qryOpenMOCs].Owner, [qryOpenMOCs].Comments
FROM (Departments INNER JOIN [qryOpenMOCs] ON Departments.[ID] = [qryOpenMOCs].[Department]) INNER JOIN qryMOCDepts ON Departments.[ID] = qryMOCDepts.[Dept];
Also, if there's a different way to do this, I'm open to suggestions!
Hopefully this makes sense... thank you in advance for any help.
Alecia