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 |
Warsha
Starting Member
4 Posts |
Posted - 2013-09-19 : 09:14:08
|
Hi all,I have a case where a need to search for a givin number, and that number should be between a begin and end number stored in a row in atble. see the table below.descr begin end qtyapple 1 200 200bags 1 400 400mangos 1 100 100apple 201 700 500if I search for apple number 17 then the query should bring me to apple 1 200 200Is it posssile?I really hope someone can help meRegards,Warsha |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-09-19 : 09:18:54
|
select * from table where [descr] = 'apple' and 17 between [begin] and [end] Too old to Rock'n'Roll too young to die. |
|
|
Warsha
Starting Member
4 Posts |
Posted - 2013-09-19 : 11:03:58
|
Thanks! That worked....regards,Warsha |
|
|
sigmas
Posting Yak Master
172 Posts |
Posted - 2013-09-19 : 11:20:30
|
select * from table where [descr] = 'apple' and 17 >= [begin] and 17 <= [end] |
|
|
|
|
|