Function to Rank Rows

  • I need to create a FUNCTION that accepts a SQL statement as a parameter and an index as the other parameter.  The SQL statement will return a single column with multiple rows.  I want the function to pass back the 1st value (row), or 2nd value, or 3rd value depending on the index parameter.

    I don't think I can pass in the SQL statement as a VARCHAR and execute it in a SQL function.  Can I pass in the results of the SQL statement as a table and have the function return the row identified by the index parameter?

    I need this to be a function because I want to call it within a column of an outer SQL statement.

    Thanks,

    Mark

     

  • Can you post your table DDL, some sample data and expected result ?

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

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