Oracle KEEP Function

  • Hi there,

    Is there any equivalent function for this in SQL 2005 SQL? I need to DENSE_RANK() a column based on the first (max)value of each TOP N paritioned group, so that I can sort the group result set by this value.

    In Oracle I use the following

    SELECT

    SELECT Group_id,

    DName,

    MaxReads,

    TopN,

    MAX (MaxReads) KEEP (dense_rank first ORDER BY topn) over (PARTITION BY Group_ID) maxRank

    FROM (TOP N Query)

  • Don't know much about oracle, but if this doesn't get answered, try a different approach. Add some sample data that can demonstrate how keep works (see the link in my signature for how to post this) and results of this oracle query and we can see if we can write an equivalent script for T-SQL. Even if there is no direct command that is the same as Keep, I'm sure the functionality of it can be duplicated.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply