Mike wrote:
> Hi. I have a datatable containing a column named 'Price'. The datatable is
> populated with records of varying prices ($1 - $50,000). How can I select
> one record from this datatable, and then determine the 5 rows that are
> closest to this record's 'Price' value?
>
> For example - Let's say the following items are rows from this datatable.
> The value shown is the 'Price' column's value for each respective row. How
> could I progamatically say "Give me the 5 closest rows to row# 2's value
> (10), and in return receive 7, 20, 100, 1000, 2000?
>
> - 7
> - 10
> - 20
> - 100
> - 1000
> - 2000
> - 3000
> - 4000
> - 5000
> - 6000
> - 7000
>
> Thanks
The absolute difference between two values is abs(value1 - value2).
Order by the absolute difference between the price and the selected
value, and select the top five records where the price is different from
the selected value.
--
Göran Andersson
_____
http://www.guffa.com