I have a simple query to throw up suppliers that have been used more than twice. Unfortunately my base data has:
Supplier, Order Number, Item
I want to group by supplier and count the unique order numbers as I may have three line items for order number 123 and two line items for 124 and want to make a quantity of 2 order numbers.The following obviously gives five:
Supplier, Order Number, Item
I want to group by supplier and count the unique order numbers as I may have three line items for order number 123 and two line items for 124 and want to make a quantity of 2 order numbers.The following obviously gives five:
Code:
SELECT tblSuppliers.Supplier, Count(tblPOrders.ONumber) AS CountOfONumber
FROM tblPOrders INNER JOIN tblSuppliers ON tblPOrders.Supplier = tblSuppliers.ID
WHERE (((tblSuppliers.SApproved) Is Null))
GROUP BY tblSuppliers.Supplier
HAVING (((Count(tblPOrders.ONumber))>2))
ORDER BY tblSuppliers.Supplier;