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, 2012 at 10:00 PM in Default

avatar image

TelepathicSheep2
140 15 15 19

(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, 2012 at 10:02 PM

avatar image

ThomasRushton ♦♦
39.9k 20 49 52

Great - that was real easy, thanks for your help!

Mar 20, 2012 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.

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:

x148
x17

asked: Mar 19, 2012 at 10:00 PM

Seen: 900 times

Last Updated: Mar 20, 2012 at 12:57 AM

Copyright 2016 Redgate Software. Privacy Policy