Hi Gavin,
First, it is helpful to define what you mean by not selling. Typically, this
might include a time period, and perhaps a minimum number of units. Try
creating the following two queries in the sample Northwind database. The
first query is a parameter query that has you enter the minimum number sold
to be considered "selling", along with a starting and ending date. You can
just as easily have these parameters picked up from text boxes on an open
form:
qryProductsSold
PARAMETERS [Enter Minimum Units] Long,
[Enter Starting Date] DateTime, [Enter Ending Date] DateTime;
SELECT [Order Details].ProductID,
Count([Order Details].ProductID) AS CountOfProductID
FROM Orders
INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID
WHERE (((Orders.OrderDate)
Between [Enter Starting Date] And [Enter Ending Date]))
GROUP BY [Order Details].ProductID
HAVING (((Count([Order Details].ProductID))>=[Enter Minimum Units]));
Note: Valid date range is
We will now use the above query to find those products that did not sell:
qryProductsThatDidNotSell
SELECT Products.ProductID, Products.ProductName
FROM Products
LEFT JOIN qryProductsSold ON Products.ProductID = qryProductsSold.ProductID
WHERE (((qryProductsSold.ProductID) Is Null));
You could also do the first query as a subquery.
Tom Wickerath
Microsoft Access MVP
http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
Gavin27 said:
Have table of Products. Have Select Query of sales by customer (sum of all
quantities of products sorted by customer). But can not figure how to run a
query to filter out all products selling, leaving only products not selling
for a report. Suspect i am thinking about it the wrong way. If anyone can
help, much apprreciated