Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Ranking

Author  Topic 

daniella415
Starting Member

2 Posts

Posted - 2005-05-20 : 16:14:20
Hopefully some genius out there can think of something better than this.

So, I need to rank several columns in a table. I could either do this with a view --or actually put the rank value in the table --like this -

pkid -- sales1 -- rank_sales1 -- sales2 -- rank_sales2 etc...

I created a functional rank table that has the pkid and the sales column and then a sequential id and I load the table ascending on salesX then update the rank column in the original table with the sequential id by associating the pk's. Does that make ANY SENSE. well, it works. but not really.

I did this in a stored proc so that I could pass in all the variables for each column/table where I needed to rank it. Problem is, it doesn't seem like SS wants to accept a variable in the from statement... is that possible?

Or does anyone know of ANOTHER way to rank columns? Such a kludge...

Any help would be MUCH appreciated!

-D

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-05-20 : 18:51:11
This sounds messy.
And probably a lot more complicated than it should be.
Please post the table DDL, what the data looks like,
and sample results of what You are trying to accomplish.

rockmoose
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2005-05-21 : 04:54:30
Just a hint here: dont think in terms of presentation of data, that can be done at the client. You are over complicating things by trying to get data into columns. Think about getting the data into rows first, then getting them into columns shouldn't be too hard. So if you can get your data like this:

Sales1 - Sales1_Rank
Sales2 - Sales2_Rank

...you will have little trouble presenting them in a cross-tab or matrix format.

OS
Go to Top of Page
   

- Advertisement -