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.
| Author |
Topic |
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2009-02-06 : 10:03:28
|
| I have a tableyear period user2006 2 Bob2006 3 Sam2006 3 Sue2006 4 Candice2007 2 Bob2007 5 MikeI want to be able to select all fields for the periods 3 and 5 in 2006to give 2006 3 Sam2006 3 Sue2006 4 CandiceHow can I do this please? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-06 : 10:06:29
|
do you mean this?select year,period,user FROM table WHERE period >= 3 AND period<5 AND year=2006 |
 |
|
|
webappguru
Starting Member
10 Posts |
Posted - 2009-02-06 : 10:51:06
|
How about this:SELECT year, period, user from table where year = 2006 and(period = 3 or period = 5)But then Candice would not show up because she is period 4. quote: I want to be able to select all fields for the periods 3 and 5 in 2006to give 2006 3 Sam2006 3 Sue2006 4 Candice
"I live for programming"www.aliabidhusain.net |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-07 : 08:44:57
|
quote: Originally posted by webappguru How about this:SELECT year, period, user from table where year = 2006 and(period = 3 or period = 5)But then Candice would not show up because she is period 4. quote: I want to be able to select all fields for the periods 3 and 5 in 2006to give 2006 3 Sam2006 3 Sue2006 4 Candice
"I live for programming"www.aliabidhusain.net
that will bring back 2007 5 Mike also |
 |
|
|
sg2255551
Constraint Violating Yak Guru
274 Posts |
Posted - 2009-02-07 : 12:25:32
|
| hiyou can also try this:select year,period,user FROM table WHERE period between 3 AND 5 AND year = 2006 |
 |
|
|
|
|
|