Reputation: 3
this is for use in Microsoft sql server management studio 2008
Hi i have this data of a running race below:
Name /fav / odds /Place
John / 3rd / 5.21 / 1st
Bob / 1st / 3.11 / 2nd
paul / 6th /10.10 / 3rd
ken / 4th / 6.11 / 4th
ted / 7th /20.44 / 5th
julie/ 8th /100.00/ 6th
rob / 9th / 22.11/ 7th
rex /10th / 33.55/ 8th
rod / 2nd / 4.11 / 9th
nub / 5th / 7.34 / 10th
1) I know how to show the 1st fav with no other conditions -> result: (Bob 1st / 3.11 / 2nd)
2) But How do i show the 1st FAV(Bob 1st / 3.11 / 2nd) only if the 3rd fav (John 3rd / 5.21 / 1st and 6 dollars) ODDS are between 5 and 6 dollars , which they are for this to work.
Results (Bob 1st / 3.11 / 2nd)
Upvotes: 0
Views: 23
Reputation: 5094
try this,
select * from table1 where fav='1st'
and exists
(select name from
table1
where fav='3rd' and odd between 5 and 6)
Upvotes: 0