UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Rank Sales in Query    
 
   
BGAccess
post Jan 31 2008, 07:13 AM
Post #1

UtterAccess Guru
Posts: 673
From: Northwest Ohio



Hello again. I have the following query:

SELECT tblProductInfo.strItemNumber, tblProductInfo.strDescription, [Units]*[lngAmtPerCase] AS [Total Units]
FROM tblProductInfo INNER JOIN tblLastYearSales ON tblProductInfo.strItemNumber = tblLastYearSales.[Item #];

I'd like to add a Rank column that will rank the items. The item that has the most [Total Units] would be ranked 1, and descending from there. I've tried a couple of things, but I obviously didn't do it right. I thought it would be pretty easy, but I couldn't figure it out (doesn't mean it's not easy).

Kevin
Go to the top of the page
 
+
alancossey
post Jan 31 2008, 07:57 AM
Post #2

UtterAccess Veteran
Posts: 401
From: Norfolk, UK



How about
1) Sorting in descending order of Total Units.
2) Adding a calculated field which is always 1.
3) Creating a running total of that calculated field.

Problems:
a) You'd have to look up on the Microsoft Knowledge Base how to calculate a running total in a query (unless you do this in a report).
b) People with exactly the same Total Units would not show as being of equal ranking.
Go to the top of the page
 
+
dashiellx2000
post Jan 31 2008, 07:57 AM
Post #3

UtterAccess VIP
Posts: 9,209
From: Maryland



Good Morning, Kevin.

Check out this thread or this one.

HTH
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 23rd May 2013 - 08:17 AM