On Jun 16, 12:18 pm, lyle fairfield <lyle.fairfi...@gmail.comwrote:
Based on your first sentence:
Assuming "Part No 2450" is a field name?
SELECT [Part No 2540], Count(*) FROM RMAS WHERE Priority = 1 GROUP BY
[Part No 2540]
or if we want "[Part No] = 2450" then
SELECT Count(*), FROM RMAS WHERE Priority = 1 AND [Part No] = 2540
On Jun 16, 10:28 am, troy_...@comcast.net wrote:
I am trying to count the total number of units for a given part number
that have a Priority rating of 1. Based upon some research, this is
what I came up with for my query. Access says that I have invalid
bracketing in the Select Distinct statement. The only brackets I
inserted were to delimit the table's field names. Access did the rest.
Also, Access created the second AS bracket group - [%$##@_Alias].
Am I barking up the right tree or is my query statement way off base?
I am not sure where to put the WHERE clause and I don't understand the
bracketing error Access is giving.
Query Statement:
SELECT COUNT(*) AS ["Planned Ships"] FROM [SELECT DISTINCT [Part No
2540] FROM RMAs WHERE [Priority] =1] AS [%$##@_Alias] GROUP BY [Part
No 2540];
Thanks in advance.
Troy Lee
Thanks for all the replies and constructive criticisms. Please
understand that I am working with a database not originally created by
me- thus all the crazy field names. As for my question, I did do some
more research and have a better grasp on what I am trying to
accomplish. I got my query to work- (aggregate values for each Part
Number type with a Priority of 1).
This is the code found in SQL view of the Query Design window.
SELECT RMAs.[Part No 2540], RMAs.[Unit Type], Count(RMAs.[RMA #]) AS
[CountOfRMA #], RMAs.Priority
FROM RMAs
GROUP BY RMAs.[Part No 2540], RMAs.[Unit Type], RMAs.Priority
HAVING (((RMAs.Priority)=1));
Now, I want to create a calculated field called Total for all of the
units found by the query. I would like to do this within the same
query, but can't quite figure it out. BTW, the field that I am
currently counting, which is also the PK for the table, is a text
field.
For clarity's sake, the field name [Part No 2540] is in reference to
the fact that we preface all of our units by the first four digits
2540. The stored values for the unit types are an additional 4 digits
appended to this number.