I'm writing a SQL function that returns the first value of a sorted list, but I really don't know how to start? The function has only one parameter which is the listing number ( `VRI.Listing_Number` )

Using `select` statement, I have:

```
SELECT  TOP 1 
        --VRI.Listing_RID, VRI.Listing_Number, VRI.Listing_Price, CH.Old_Price, CH.Date_Time_Changed
        CH.Old_Price
FROM    dbo.View_Report_Information_Tables VRI WITH (NOLOCK) 
        INNER JOIN dbo.MLS_Change_History CH WITH (NOLOCK) ON
            VRI.Listing_RID = CH.Listing_RID
        INNER JOIN dbo.MLS_Change_History_Type CHT WITH (NOLOCK) ON
            CH.Transaction_RID = CHT.Transaction_RID
WHERE   CHT.Change_Type_Display = 3 AND
        VRI.Listing_RID = CH.LISTING_RID
ORDER BY CH.Transaction_RID DESC

```

This sql query returns the last price changes from a list of prices. 

I'm really new to sql, so I even don't understand quite well the syntax. For example, I looked up the `CH.Old_Price`, and I saw it `TYPE_NAME` is `numeric`, but it also has length and precision, scale.... What should my return value for this function?

Any idea? 

Thanks,