Welcome to Sign in | Join | Help
in Search

dense_rank()

Last post 01-11-2013, 2:09 PM by neo. 4 replies.
Sort Posts: Previous Next
  •  01-11-2013, 1:36 PM 9507

    dense_rank()

    Salut,

       Exista posibilitatea de a utiliza functia dense_rank() astfel incat rank-ul sa inceapa cu un anumit ID specificat de mine?

    Multumesc.

    G.
  •  01-11-2013, 1:49 PM 9508 in reply to 9507

    Re: dense_rank()

    Poți să aduni, pur și simplu, valoarea dorită (minus 1).
  •  01-11-2013, 1:58 PM 9509 in reply to 9508

    Re: dense_rank()



    Multumesc.

    G.
  •  01-11-2013, 2:07 PM 9510 in reply to 9508

    Re: dense_rank()

    Uite și un exemplu:

    USE tempdb

    DECLARE @Result TABLE (
    ObjectName sysname,
    ColumnName sysname,
    TheRank int
    )

    INSERT INTO @Result
    SELECT o.name, c.name, DENSE_RANK() OVER (ORDER BY o.name)
    FROM sys.columns c
    INNER JOIN sys.objects o ON c.object_id = o.object_id
    WHERE o.type='S'

    INSERT INTO @Result
    SELECT o.name, c.name, DENSE_RANK() OVER (ORDER BY o.name)+ISNULL((SELECT MAX(TheRank) FROM @Result),0)
    FROM sys.columns c
    INNER JOIN sys.objects o ON c.object_id = o.object_id
    WHERE o.type<>'S'

    SELECT * FROM @Result

    Răzvan
  •  01-11-2013, 2:09 PM 9511 in reply to 9510

    Re: dense_rank()

    Merci frumos


    Gabi

    G.
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems