Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2007-07-25 : 09:12:15
|
Simple table.ID Price1 241562 16003 97874 787765 2000I need to return the id where the price is nearest to 1700, in this example I would want id 2Can it be done?Thanks |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-25 : 09:40:19
|
[code]select top 1 *from simple_tableorder by abs(1700 - Price)[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2007-07-25 : 10:08:53
|
Cheers! |
|
|
|
|
|