2

For example:

name | startyear | endyear 
jon    2003       2005
jake   1999       2002
blake  1997       1998
jake   1995       1996
jason  1993       1994

Is there a way to return blake?

I want to know who was treasurer between the two terms of jake.

3
  • It's not clear what you want. Can you give a bit more explanation and a few more examples to clarify? Commented Feb 6, 2011 at 9:20
  • 1
    Duplicate of stackoverflow.com/questions/4912293/… Maybe you two are in the same classroom. Commented Feb 6, 2011 at 9:27
  • this is a different question because it has a different criteria. Commented Feb 6, 2011 at 9:30

2 Answers 2

2

You could use between, like:

select  yt.name
from    YourTable yt
where   TheYear between yt.startyear and yt.endyear

between is inclusive, so this would return Blake for TheYear = 97 and 98.

Sign up to request clarification or add additional context in comments.

Comments

2

Without more information, this is the best suggestion I can give:

SELECT name 
FROM your_table
WHERE startyear > (SELECT min(endyear) FROM your_table WHERE name = 'jake')
  AND endyear   < (SELECT max(startyear) FROM your_table WHERE name = 'jake')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.