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)
 Column Alias w/Exception

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-08-27 : 11:25:51
Kapoppie writes "I need to develop a stored proc that has a parameter for @Name and takes this:

Reading in a parameter and value of:
@Name = Andrew

Name Average

Jason 66
Tony 88
Andrew 11
Betty 99

And...makes the output look like this:


Rank Name Average

1 Name 1 99
2 Name 2 88
3 Name 3 66
4 Andrew 11"

nr
SQLTeam MVY

12543 Posts

Posted - 2002-08-27 : 11:31:35
select rank = (select count(*) from tbl t2 where t2.average >= tbl.average) ,
name = case when name = @Name then Name else 'Name' end
Average
order by rank

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -