Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Towards the innovative SQL ideas
Browse by Tags · View All
ms sql server 119
ms sql 118
sql server 116
sql 115
database 102
tsql 81
#SQL Server 78
t-sql 75
#sql 71
sql server general 67

Archive · View All
April 2011 14
July 2011 12
May 2011 12
August 2011 11
June 2011 10
September 2011 8
December 2011 6
November 2011 6
June 2013 5
April 2013 5

Working with Ranking Functions - SQL Server 2005

Apr 5 2011 10:32AM by Paresh Prajapati   

I have learn so many times about ranking functions but never got chance to used with them. But during development some of the stored procedures, i have get the best chance to practically use.
With ranking function , it really reduce the code complexity and also i enjoyed more while utilized them in stored procedures development. Below are some examples of various ranking functions.
 
Creating table to test Ranking Functions.
CREATE TABLE tbl_RankingFunctionTest
(
[Id] SMALLINT,
)
 Inserting records in table created above.
INSERT INTO tbl_RankingFunctionTest VALUES(1); 
INSERT INTO tbl_RankingFunctionTest VALUES(8); 
INSERT INTO tbl_RankingFunctionTest VALUES(9); 
INSERT INTO tbl_RankingFunctionTest VALUES(46); 
INSERT INTO tbl_RankingFunctionTest VALUES(18); 
INSERT INTO tbl_RankingFunctionTest VALUES(1); 
INSERT INTO tbl_RankingFunctionTest VALUES(1); 
INSERT INTO tbl_RankingFunctionTest VALUES(2); 
INSERT INTO tbl_RankingFunctionTest VALUES(2); 
 Lets run script to check the result of ranking functions.
SELECT 
[Id], 
ROW_NUMBER() OVER (ORDER BY ID) AS 'ROW NUMBER', 
ROW_NUMBER() OVER (PARTITION BY ID ORDER BY ID) AS 'ROW NUMBER WITH PARTITION', 
RANK() OVER (ORDER BY ID) AS 'RANK', 
DENSE_RANK() OVER (ORDER BY ID) AS 'DENSE RANK', 
NTILE(2) OVER (ORDER BY ID) AS 'NTILE' 
FROM tbl_RankingFunctionTest 
ORDER BY [ID] 
From the result by above script, In the image you can see the out for the various ranking function for ID 1 and 2 which marked.

Tags: sql, sql server 2008, sql server 2005, tsql, sql server, ms sql, sql server errors, ms sql server, t-sql, sqllserver, ranking functions, mssql,


Paresh Prajapati
6 · 22% · 7054
1
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"Working with Ranking Functions - SQL Server 2005" rated 5 out of 5 by 1 readers
Working with Ranking Functions - SQL Server 2005 , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]