mhartman1
Technical User
- May 5, 2006
- 155
Hi,from I have been trying to get this query to work using the Microsoft Access Northwind database:
The first SQL statement works fine but the second one gives an "Object invalid or no longer set." error.
The problem seems to be with the "Where" clause of the subquery statement.
If that is removed, It returns a ranking of 77 for each record.
Thanks in advance for any help
Mark
CODE from the article here:
----------------------------
SELECT ProductName,
SUM(Quantity) AS TotalSales
FROM [Order Details] INNER JOIN Products
ON [Order Details].ProductID =
Products.ProductID
GROUP BY ProductName
ORDER BY SUM(Quantity) DESC
After that query has been saved as qryProductTotals, you can use this query with a subquery to generate the sales rankings:
SELECT ProductName, TotalSales,
(SELECT COUNT(*)
FROM qryProductTotals AS QPT
WHERE qryProductTotals.TotalSales
<= QPT.TotalSales) AS Rank
FROM qryProductTotals
ORDER BY TotalSales DESC
----------------------------
The first SQL statement works fine but the second one gives an "Object invalid or no longer set." error.
The problem seems to be with the "Where" clause of the subquery statement.
If that is removed, It returns a ranking of 77 for each record.
Thanks in advance for any help
Mark
CODE from the article here:
----------------------------
SELECT ProductName,
SUM(Quantity) AS TotalSales
FROM [Order Details] INNER JOIN Products
ON [Order Details].ProductID =
Products.ProductID
GROUP BY ProductName
ORDER BY SUM(Quantity) DESC
After that query has been saved as qryProductTotals, you can use this query with a subquery to generate the sales rankings:
SELECT ProductName, TotalSales,
(SELECT COUNT(*)
FROM qryProductTotals AS QPT
WHERE qryProductTotals.TotalSales
<= QPT.TotalSales) AS Rank
FROM qryProductTotals
ORDER BY TotalSales DESC
----------------------------