473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

auto numbering

Hello,

For analyses and reporting I would like to add a 'ranking' to a
table/view.
Example:
Using the 'order by desc' clause in query I get a list of Customers
ordered by Turnover (descending). I would like to add that ranking
numbers (same as recordnumbers) in the query. I would like to have the
following result:
Cust_nr Cust_Name Turnover_2004 Ranking
002234 Bayer 139.000 1
003456 Rentokill 123.456 2
001231 Air France 105.000 3
etc.

When the 'ranking' is part of the query/table I can use this ranking in
an other query.

Important: This questions is not about making an (empty) table structure
for filling in by an application and generating a new unique number each
time a record is added.

I hope you can help me.

Thanks,

Hans

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #1
2 1330
On 10 Mar 2005 03:14:43 -0600, Hans de Korte wrote:
Hello,

For analyses and reporting I would like to add a 'ranking' to a
table/view.
Example:
Using the 'order by desc' clause in query I get a list of Customers
ordered by Turnover (descending). I would like to add that ranking
numbers (same as recordnumbers) in the query. I would like to have the
following result:
Cust_nr Cust_Name Turnover_2004 Ranking
002234 Bayer 139.000 1
003456 Rentokill 123.456 2
001231 Air France 105.000 3
etc.

When the 'ranking' is part of the query/table I can use this ranking in
an other query.

(snip)

Hi Hans,

I'd recommend against storing it in the table, as you'll need to update
all rankings each time some data in the table changes. (Of course, if
you have a static database, where data won't change but that you have to
run extensive reports off, things change).

In a live database, I'd define a view to hold the ranking:

CREATE VIEW CustomersRanked
AS
SELECT Cust_nr, Cust_Name, Turnover_2004,
(SELECT COUNT(*)
FROM Customers AS b
WHERE b.Turnover_2004 > a.Turnover_2004) + 1 AS Ranking
FROM Customers AS a
ORDER BY Turnover_2004 DESC
(untested)

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 23 '05 #2

Thanks, the soluttion is working excellent!!

Regards,

Hans
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Steven Burn | last post by:
I'm curious, I've written a very simple PIS (personal info store) that allows one to store whatever they wish..... the problem is, when one deletes an entry, the auto-numbering isn't corrected to...
5
by: Charles McCaffery | last post by:
I have written a database with auto-numbering and now wish to remove alkl of my test data and set the auto-numbering back to one. How do I do this please? Charles McCaffery.
6
by: MJ | last post by:
No one answered my original e-mail--it probably wasn't clear. I am hoping this makes the question a little clearer. Is it possible to combine both letters and numbers in an auto number? I can't...
3
by: Chris | last post by:
Before I started to create table, etc to track unique form field record number assigments I thought I'd check to see if there is now a better way to do this in .NET. I have a parent form (table)...
0
by: jimratajski | last post by:
Can anyone tell me how to automate page numbering of spawned page templates in Acrobat? I have a number of forms containing hidden page templates that I would like to be auto numbered as they are...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.