December 23, 2009 at 1:18 am
Hi,
Any info on how to sort and rank 4 columns at the same time.
I have 4 columns
Select Salary, TransAllowance, HouseAllw, Cash from Payroll
1st column should be asc - the first will get number 1 pts
2nd column should be asc - 1 first will get number 1 pts
2 will get 2 pnts
last will get the last number of recound cnt
3rd column should be desc - opposite of 1 and 2 columns
4th column should be asc - same as 1st column
Result :
Record 1 1,000 (1pt) 500 (1pts) 2,000 (1 pts)
Record 2 1,500 (2pt) 800 (2pts) 1,000 (2 pts)
Thanks
Dabuskol
December 23, 2009 at 1:37 am
Hi,
Could you post some sample data, along with the code you've tried so far, so we can help:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
BrainDonor
Edit to use hyperlink.
December 23, 2009 at 2:46 am
SqlUser-369680 (12/23/2009)
Hi,Any info on how to sort and rank 4 columns at the same time.
I have 4 columns
Select Salary, TransAllowance, HouseAllw, Cash from Payroll
1st column should be asc - the first will get number 1 pts
2nd column should be asc - 1 first will get number 1 pts
2 will get 2 pnts
last will get the last number of recound cnt
3rd column should be desc - opposite of 1 and 2 columns
4th column should be asc - same as 1st column
Result :
Record 1 1,000 (1pt) 500 (1pts) 2,000 (1 pts)
Record 2 1,500 (2pt) 800 (2pts) 1,000 (2 pts)
Thanks
Dabuskol
Can you please confirm that you are using SQL Server 7/2000?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply