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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 complex Query

Author  Topic 

moiseszaragoza
Starting Member

8 Posts

Posted - 2009-06-27 : 21:11:37
I need to select a range of things
like
SELECT * FROM TABLE
WHERE
(DOB < lowDate AND DOB > hiDate)
AND
(ShoeSize < lowNum AND ShoeSize > hiNum)

Is this correnct?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-28 : 00:41:23
the syntax looks fine. to suggest if query will give you what you're looking for we need to understand what you're trying to achieve. can you explain your requirement using some sample data and desired o/p in below format

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-28 : 12:36:10
This selection retieves only younger and older people AND only little feet and big feet because your given "range" is not between the given values.
Is that what you want?

Fred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

moiseszaragoza
Starting Member

8 Posts

Posted - 2009-06-28 : 14:01:09
Well well what i need is to be able to select ranges of difent valujes.

like every one that is 15 to 20 and have a shoe side of 8 to 12

Just keep smiling
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-28 : 14:18:56
then i think what you need is

SELECT * FROM TABLE
WHERE
(DOB >= 15 AND DOB <= 20)
AND
(ShoeSize >= 8 AND ShoeSize <=12)
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-28 : 14:36:31
See http://weblogs.sqlteam.com/peterl/archive/2009/04/01/One-way-to-calculate-decimal-year.aspx
how to calculate age.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -