Can I override a column's value in Select CASE SQL

case, sql

Solution

Try this:

Select     
    jobTitle, 
      CASE WHEN jobtitle like '%DEVELOP%' 
      THEN bigBossTitle 
      ELSE managerTitle 
      END as managerTitle, 
    bigBossTitle,

From PeopleTable
inner join... other tables...

You just put the case statement where the managerTitle column was and then alias the result as managerTitle. This logic effectively gives you what you're looking for. To actually "replace" a value you would need to do more advanced T-SQL and it's not really necessary.

Example of using a case statement in a join predicate:

...
inner join otherTable 
on otherTable.bossTitle = 
      CASE WHEN jobtitle like '%DEVELOP%' 
      THEN bigBossTitle 
      ELSE managerTitle 
      END

Problem

Can I override a value in a column such that if a case is true, it tells value x to be equal to another dynamic value in the query. Here's pseudocode. I know this doesn't work. ``` Select jobTitle, managerTitle, bigBossTitle, CASE WHEN jobtitle like '%DEVELOP%' THEN managerTitle = bigBossTitle END From PeopleTable inner join... other tables... ``` Thanks.

Original source