SQL Conditional column data return in a select statement

You didn’t mention your DBMS but a searched CASE statement works in all major DBMS’s I know off.

SELECT  ID
        , CASE WHEN WorkStream = 'Internal'
               THEN WorkStream
               ELSE Assignee
          END AS Assignee
        , Workstream
FROM    assignees

Reference: MSDN

CASE

Evaluates a list of conditions and returns one of multiple possible
result expressions.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)