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 |
Sql_forum
Yak Posting Veteran
50 Posts |
Posted - 2012-06-21 : 05:29:27
|
Hi all,I have a table which has data looks as follows:A B1 101 101 103 153 153 155 185 185 18Here B' column is filtered based on where condition1. if the input i m passing in where condition is 12 then i want to select rows looks as below :3 153 153 152. if the input is 17 , the data should fetch 5 185 185 18Can any one help me?? |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-21 : 05:55:22
|
select * from tbl where B = (select min(B) frrom tbl where B > @inpno)==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-06-21 : 07:29:15
|
Another way would be to use TOP clause as inSELECT TOP (1) WITH TIES A,BFROM tbl WHERE b > @inpnoORDER BY b ASC |
 |
|
|
|
|