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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 create new column base on values other columns

Author  Topic 

eugz
Posting Yak Master

210 Posts

Posted - 2012-05-11 : 11:52:09
Hi All.

I have two fields StartDate and EndDate and I would like to make base on them value new column "Filter". What I mean. If StartDate is not null and EndDate is null then column "Filter" get value Active. If EndDate is not null then column "Filter" get value Inactive. If it is possible how it to do?

Thanks.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-05-11 : 12:18:39
[code]SELECT
StartDate,
EndDate,
CASE WHEN StartDate IS NOT NULL AND EndDate IS NULL THEN 'Active' ELSE Inactive END AS Filter
FROM
YourTable
[/code]
Go to Top of Page

eugz
Posting Yak Master

210 Posts

Posted - 2012-05-11 : 12:49:12
Hi sunitabeck. Thanks for replay.
Go to Top of Page
   

- Advertisement -