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 |
|
amgrace
Starting Member
30 Posts |
Posted - 2004-07-13 : 10:50:42
|
| Hello guys,I am having a mind/memory-block and can't seem to remember how to write this straight-forward query. PLEASE HELP!!!!!!Okay, here's what I've got so far (but i am not sure its correct):SELECT * from mytableWHERE Status = ‘N’And Code like ‘New%’And EpisodeEndDate between Between '01/04/2004' And ‘29/04/2004'OR AttendanceDate Between '01/04/2004' And ‘29/04/2004'#I need this query to retrieve everything with a Status of 'N', and Code like 'NEW' and then has EITHER EpisodeEndDate or AttendanceDate of between '01/04/2004' And ‘29/04/2004'.So really, in total, I have 3 criteria and not 4 for the query i.e. it either (Status, code and EpisodeEndDate) or (Staus, Code and AttemdanceDate).Hope I am making sense.ThanksGrace |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-07-13 : 10:53:29
|
| The or must reside inside a pair of "()"SELECT * from mytableWHERE Status = ‘N’And Code like ‘New%’And (EpisodeEndDate between Between '01/04/2004' And ‘29/04/2004'OR AttendanceDate Between '01/04/2004' And ‘29/04/2004')Duane. |
 |
|
|
amgrace
Starting Member
30 Posts |
Posted - 2004-07-13 : 11:20:25
|
| That's it!Thanks very much indeed. |
 |
|
|
|
|
|