Ranking records

G

Guest

Hello,
I have a query to report on sales results.
what i would like to do in the query is to rank sales items by total sales
so ex
clothing $500
Jewlery $1000


i would like Jewlery to be ranked as 1 and
clothing as 2
and etc
seems simple but
everything i have tried does not work.
 
G

Guest

Create a Totals query.
Make item Group By
Make Total Sales Sum
Order by Total Sales Descending
 
G

Guest

thanks
how would i pop a field in the query to reflect the ranking?
field would actually have values of 1 2 3 etc in it
 
M

Marshall Barton

Schuitkds said:
I have a query to report on sales results.
what i would like to do in the query is to rank sales items by total sales
so ex
clothing $500
Jewlery $1000


i would like Jewlery to be ranked as 1 and
clothing as 2
and etc
seems simple but
everything i have tried does not work.


Add a calculated field to the query. The general idea is:

Rank: (SELECT Count(*)
FROM table As X
WHERE X.totalsales <= table.totalsales)

It's may be more complicated than that if your query has
grouping and/or criteria.

If you have problems getting it work in your situation,
please post a Copy/Paste of your query's SQL statement.
 
G

Guest

I know it can be done, but I don't know how.

Schuitkds said:
thanks
how would i pop a field in the query to reflect the ranking?
field would actually have values of 1 2 3 etc in it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top