Solved

Access Query Sequential Numbering (After a sort)

Posted on 2007-11-20
5
604 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 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

696 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