SQL Server 2005: Select One Column If Another Column Is Null or Contains a Word -
i trying create report using bids. want 1 of columns provide email address. have 2 tables containing email addresses. 1 contains original email address customer provided when started doing business us. other table contains possibly updated (alternate) email address submitted on website.
sometimes original email address uses our company domain because company use create emails clients did not have address.
i need construct query evaluate original email address. needs 2 things:
- if original email address blank, needs include alternate email address.
- if original email address contains our domain (customer@mydomain.com), needs include alternate email address.
- if 2 items above not case, needs spit out original email address.
the query need spit out evaluation single column called email.
can done? should towards bids instead? if so, direction?
thanks in advance help.
easy peasy using case. like:
select whatever1, whatever2, case when originalemail null alternateemail when originalemail '%domainname%' alternateemail else originalemail end email from...
Comments
Post a Comment