Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Need help with range selection

$
0
0
 I have a dog database that users will need to select (among other criteria) breeds by size. The problem I'm struggling with is how to select those breeds that weight range span sizes. Some dogs, e.g. American Eskimo, span multiple sizes. In this case,  Toy, Small and Medium sizes.    See below...

The dog breed weight selections are:

Toy          < 12lbs
Small     12-24 lbs
Medium 25-49 lbs
Large    50-99 lbs
X-Large 100+ lbs

Sample data:

Breed                   MinWeight   MaxWeight
Affenpinscher          6                13
American Eskimo    7                40
Yorkipoo                3                18
BigDog                   35              65

If a user needs all dogs that have a weight of 10lbs or below, and I write a simplistic select on the above data using between minweight and maxweight I will get an empty result set. Not sure if I explained this well enough. I'm new to SQL and am wondering if the/a solution involves much more. Any thoughts?

Thank you

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>