• dob111283 (6/17/2013)


    I'm sorry Shawn, as a relative newbie to SQL, I'm not properly clarifying things. When you wrote sometable, I realize that's whatever table I'm trying to pry the information from into the current stored procedure or function that I'm working on. That "sometable" is the dbo.PEX_ClearedTransactions stored procedure I'm trying to get all the relative information from, into the new stored procedure/function i'm trying to create, which is the PEX_MetricsTopFiveStrongest. Also Shawn, why do you use Top 5? Can I also do an ORDER BY and use OFFSET 0 ROWS FETCH FIRST 5 ROWS ONLY?

    I used top 5 because your requirements said to retrieve the top 5. 😛

    Look at the recent example I posted. There is no particular reason for top 5. I could just as easily made that example proc get all items from sys.objects but that is a lot of information to retrieve for a simple example. Since you are in 2012 you could use OFFSET but it would do the same thing as top 5. 😀 Regardless of the method you use to get the "top 5" you MUST specify an order.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/