x

Select Statement, Where clause help - need to select active projects & closed projects from this year

I have a very simple question (I think):
I know how to do this using two queries:

Select * from TABLE
WHERE PROJECT_STATUS LIKE 'ACTIVE';

and...

Select * from TABLE
WHERE PROJECT_STATUS LIKE 'CLOSED' AND COMPLETION-DATE > '2011-01-01';

but, I'd like to do this in one query, how would I do that?
Any suggestions would be appreciated. Thanks

more ▼

asked Mar 19 '12 at 10:00 PM in Default

TelepathicSheep2 gravatar image

TelepathicSheep2
140 14 14 17

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

So, what you want is to select Active projects OR projects that are closed with a completion date after 2011-01-01:

SELECT * FROM TABLE
WHERE (PROJECT_STATUS LIKE 'ACTIVE')
   OR ( (PROJECT_STATUS LIKE 'CLOSED') AND (COMPLETION-DATE > '2011-01-01') )
more ▼

answered Mar 19 '12 at 10:02 PM

ThomasRushton gravatar image

ThomasRushton ♦
33.3k 14 20 44

Great - that was real easy, thanks for your help!
Mar 20 '12 at 12:52 AM TelepathicSheep2
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x103
x11

asked: Mar 19 '12 at 10:00 PM

Seen: 652 times

Last Updated: Mar 20 '12 at 12:57 AM