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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Range Between Values in 2 Columns

Status
Not open for further replies.

JTechMan

Programmer
Jun 15, 2009
23
CA
I have been trying to select a range where for instance

Code:
(col1 >= 2010 and col2 >=1) or (col1 <=2011 and col2 <= 10)

I am sure this is possible so any help would be appreciated!!
 
It's hard to tell, but it looks like you want something like this:

[tt]
Where Col1 Between 2010 and 2011
And Col2 Between 1 and 10
[/tt]

It's extremely possible that I misunderstood your question. If the above code snippet doesn't help, please post some sample data and expected results.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
That is sort of the idea, however, I am not sure if that will work if the criteria for col2 is the same. Interpret it as a year/month configuration for col1/col2.

So if I have this
Code:
col1	col2
2001	1
2009	2
2010	1
2010	2
2010	3
2011	1
2011	2

And want to end up with this

Code:
col1	col2
2010	1
2010	2
2010	3
2011	1

Using lower criteria 2010/1 and upper criteria 2011/1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top