Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft Access

Status
Not open for further replies.

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
----------------------------
 
Hi Duane.

Thanks for taking the time to respond. Over the weekend, I solved the problem. The problem is that I needed to upgrade the database engine for Office 2002 on my laptop that runs Windows Vista. I went that route when I ran the same queries on my desktop computer that was running Windows XP and Office 2002 and the queries ran fine.
Thanks again.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top