We help IT Professionals succeed at work.

T-SQL SELECT statement with CASE

conrad2010
conrad2010 used Ask the Experts™
on
I have a simple select statement from a Project table... in one column I would like the AKA_1 value (if it is not null) and the "Title" value if the AKA_1 value is null

SELECT
        P.ProjectID      
        ,CASE (P.AKA_1)
      WHEN NULL THEN P.Title
      ELSE P.AKA_1
      END AS Title
    FROM Projects P
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
select ISNULL( P.AKA_1, P.Title )
from Projects P
forgot to alias the resulting column:

select ISNULL( P.AKA_1, P.Title )  AS Title
from Projects P
I also left out the ProjectID column, but you get the idea.  :)
Commented:
SELECT
        P.ProjectID, ISNULL(P.AKA_1,  P.Title) AS Title
    FROM Projects P