• Based on your posted requirements:

    Here is what I am supposed to do:

    See if you can create a stored procedure based on requirements below:

    Title: PEX_MetricsTopFiveStrongest

    Summary: This stored procedure will take the passed in LPPProgramID and DateTimePoint parameters and return top 5 program ProgramIDs (uniqueidentifier) based on real time exchange rates. The exchange rate is the ratio of most recent cleared transaction point amount of the LPPProgramID to the other program transaction point amount.

    Parameters:

    - LPPProgramID (uniqueidentifier) - this will be the the programID against to compare the other programs when comparing the exchange rates - DateTimePoint (DateTime) - this will be the date/time of interest at which to calculate the exchange rate

    Returns:

    5 programIDs(uniqueidentifier)

    I would look into making this an iTVF instead of a stored proc. That way you can join to it like any other table.

    Something like this:

    create function PEX_MetricsTopFiveStrongest

    (

    @LPPProgramID int,

    @DateTimePoint datetime

    )

    returns table as

    return

    select top 5 [Columns]

    from SomeTable

    where LPPProgramID = @LPPProgramID

    and DateTimePoint = @DateTimePoint

    _______________________________________________________________

    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/