L
Leslie Isaacs
Hello All
I have been wrestling for ages now with a query that I thought would be
simple .. but can't get the output I want!
I have a table [practice suppliers] with fields SUPPLIER and AUTO CATEGORY
(and others). The field SUPPLIER is not a unique (key) field, but in fact it
almost is: ~95% of the records in the table contain unique values in this
field.Of the remaining ~5%, about half of the records for a given SUPPLIER
value contain the same value of AUTO CATEGORY, and the other half contain
different values for AUTO CATEGORY.
I want a query that will return the number of different values of AUTO
CATEGORY for each SUPPLIER. For the ~90%, and the first half of the
remaining ~5% (as referred to above), the query should return '1' as the
number of different values of AUTO CATEGORY ... but for the other half of
the ~5% it should return the actual number of different AUTO CATEGORY values
for the SUPPLIER.
My attempts (which seem to keep coming back to the one below) keep returning
the total number of AUTO CATEGORY values for each SUPPLIER - e.g. where
there are 8 records in the table with the same value of SUPPLIER and AUTO
CATEGORY, my query returns '8' - whereas it should return '1'. If the same
SUPPLIER appears 8 times with, say, 5 different AUTO CATEGORY values, the
query should return '5'.
Hope someone can help - this is driving me nuts!
Thanks for any help.
Leslie Isaacs
My 'attempt':
SELECT [practice suppliers].SUPPLIER, Count([practice suppliers].[AUTO
CATEGORY]) AS [CountOfAUTO CATEGORY]
FROM [practice suppliers]
GROUP BY [practice suppliers].SUPPLIER;
I have been wrestling for ages now with a query that I thought would be
simple .. but can't get the output I want!
I have a table [practice suppliers] with fields SUPPLIER and AUTO CATEGORY
(and others). The field SUPPLIER is not a unique (key) field, but in fact it
almost is: ~95% of the records in the table contain unique values in this
field.Of the remaining ~5%, about half of the records for a given SUPPLIER
value contain the same value of AUTO CATEGORY, and the other half contain
different values for AUTO CATEGORY.
I want a query that will return the number of different values of AUTO
CATEGORY for each SUPPLIER. For the ~90%, and the first half of the
remaining ~5% (as referred to above), the query should return '1' as the
number of different values of AUTO CATEGORY ... but for the other half of
the ~5% it should return the actual number of different AUTO CATEGORY values
for the SUPPLIER.
My attempts (which seem to keep coming back to the one below) keep returning
the total number of AUTO CATEGORY values for each SUPPLIER - e.g. where
there are 8 records in the table with the same value of SUPPLIER and AUTO
CATEGORY, my query returns '8' - whereas it should return '1'. If the same
SUPPLIER appears 8 times with, say, 5 different AUTO CATEGORY values, the
query should return '5'.
Hope someone can help - this is driving me nuts!
Thanks for any help.
Leslie Isaacs
My 'attempt':
SELECT [practice suppliers].SUPPLIER, Count([practice suppliers].[AUTO
CATEGORY]) AS [CountOfAUTO CATEGORY]
FROM [practice suppliers]
GROUP BY [practice suppliers].SUPPLIER;