?
Solved

Access Query Sequential Numbering (After a sort)

Posted on 2007-11-20
5
Medium Priority
?
605 Views
Last Modified: 2008-02-01
I have a simple query that summarizes sales by region and sorts the results in decending order.

I end up with a list of sales regions greatest to smallest (with counts of stores).

What I then need to do is make a new table that ranks these regions 1 to whatever, highest volume to lowest.
SELECT tdataStores.StrDMACity AS DMA, Sum([TblFY07-VolAndPen].FY07Vol) AS FY07_Vol, Count(tdataStores.StrID) AS Stores
FROM tdataStores INNER JOIN [TblFY07-VolAndPen] ON tdataStores.StrID = [TblFY07-VolAndPen].StrId
GROUP BY tdataStores.StrDMACity
ORDER BY Sum([TblFY07-VolAndPen].FY07Vol) DESC;

Open in new window

0
Comment
Question by:kb1esx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20321460
see this link
How to Rank Records Within a Query
http://support.microsoft.com/?kbid=208946
0
 
LVL 18

Accepted Solution

by:
jmoss111 earned 2000 total points
ID: 20321724
You could build a function
declare var
Dim Cntr as Integer
set value
Cntr = 1

Function VolCntr(x)
VolContr = Cntr
Cntr = Cntr + 1
End Function

A make table query

SELECT VolCntr ([FY07Vol]) AS Rank, etc, etc INTO MyRankTable FROM TableInYourExample
0
 
LVL 18

Expert Comment

by:jmoss111
ID: 20321733
VolCntr = Cntr
0
 

Author Comment

by:kb1esx
ID: 20321897
What was the second post for jmoss111?
0
 
LVL 18

Expert Comment

by:jmoss111
ID: 20322469
Statement under Function was misspelled s/b VolCntr was VolContr
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question