Solved

add a case statement to three existing columns. Else do substring

Posted on 2013-11-15
2
335 Views
Last Modified: 2013-11-15
select column1 from table1

if column1='bob', write 'bob evans'

select case column1 when 'bob' then 'bob evans' else column1 end as MyColumn
from table1


How to add this new case statement to this existing query
select substring(profile_id,1,3),substring(sender,1,3),message_id, substring(this_user,1,3)

where 'bob' can be profile_id, sender, this_user

NOTE: I want 'bob evans' else three letters of column name
Do not do substring if 'bob evans'
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 24

Accepted Solution

by:
mankowitz earned 500 total points
ID: 39651161
select
   case profile_id when 'bob' then 'bob evans' else substring(profile_id,1,3) end,
   case sender when 'bob' then 'bob evans' else substring(sender,1,3) end,
   message_id,
   case this_user when 'bob' then 'bob evans' else substring(this_user,1,3) end
0
 

Author Closing Comment

by:rgb192
ID: 39651917
Thanks for the query
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question