Use of RANK() and Partition by clause in SQL-Server 2005

Use of RANK()  and Partition by clause in SQL-Server 2005

We will start by creating one table for demonstration and enter some records in it.

–Create one table

CREATE TABLE BlogCount

(

BloggerName VARCHAR(10),

Topic VARCHAR(15),

[Year] INT,

Total INT

)

 This Article is move to here in “Extreme-Advice.com

Sorry for the inconvenience.

 

13 Responses to “Use of RANK() and Partition by clause in SQL-Server 2005”

  1. Pages tagged "rank" Says:

    […] bookmarks tagged rank Use of RANK() and Partition by clause in SQL-Serve… saved by 3 others     rokgod bookmarked on 03/08/09 | […]

  2. jayanti Says:

    if want output as follows
    alka sql
    .net
    ritesh sql
    .net

  3. vincenzo Says:

    Thanks for the hints guys , it works beautifully :o)

  4. Dhiraj Says:

    How can we implement as normal query ?

  5. Raju Says:

    Query

    I have a list of runners and their race times and ages. Write a
    Query to display the runners sorted by finish time with a column showing
    their finish position (ranking) within their age group.

    The age groups are
    0 – 15 years
    16 – 29 years
    30+ years

    Name Time Age
    ——————–
    Steve 12 33
    Tim 34 28
    Mark 22 37
    Tom 21 30
    Cliff 13 33
    Vini 17 28
    Matt 10 28
    Ben 9 29
    Brandon 15 14

    Output should be like below

    Name Time Age Ranking
    ===== ==== === =======
    Ben 9 29 1
    Matt 10 28 2
    Steve 12 33 1
    Cliff 13 33 2
    Brandon 15 14 1
    Vini 17 28 3
    Tom 21 30 3
    Mark 22 37 4
    Tim 34 28 4

  6. Paddy Says:

    Very clear explanation, thanks!

  7. Wenhsiu Says:

    This rocks!! Many thanks for sharing!!

  8. Ravi Gupta Says:

    This helped me. Thanks a lot 🙂

  9. Elegant Themes, woothemes, themforest, premium wordpress template, free wordpress Says:

    Elegant Themes, woothemes, themforest, premium wordpress template, free wordpress…

    […]Use of RANK() and Partition by clause in SQL-Server 2005 « Ritesh’s Blog for SQL-SERVER & .NET[…]…


Leave a comment