Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Between Vs GT/LT Comparrisons 1

Status
Not open for further replies.

kjv1611

New member
Jul 9, 2003
10,758
US
I just want to make really sure I've got this down pat.

Using the Between or Not Between statement will give you an "inclusive" argument/result, and GT/LT arguments will give "exclusive" artuments/results?

For example, is this correct:

If I say "WHERE a is BETWEEN 1 AND 10, then the results could include:
1
5
8
10

If I say GT 1 and LT 10 then the results would only include:
5
8

Of the above list.


Is that correct, or am I missing something? I just want to make sure I'm understanding this correctly before I go and try to possibly correct some of my own old SQL code for a summary query.

Thanks in advance for any help/suggestions/references.

--

"If to err is human, then I must be some kind of human!" -Me
 
You understand it correctly.

To test...

Code:
Declare @Temp Table(Data Int)

Insert Into @Temp Values(1)
Insert Into @Temp Values(5)
Insert Into @Temp Values(8)
Insert Into @Temp Values(10)

Select * From @Temp Where Data Between 1 and 10

Select * From @Temp Where Data > 1 and Data < 10

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Thanks for that confirmation, and the reminder of how easily I could test such a thing! I never seem to remember that. Perhaps one day I'll remember when I need it! [wink]


--

"If to err is human, then I must be some kind of human!" -Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top