Link to home
Start Free TrialLog in
Avatar of binaryman101
binaryman101Flag for United States of America

asked on

If a specific result is displayed in a query display null instead

I have a simple query that pulls from two tables, one of the tables is called accounts and the other is called agents.  They are joined by the AGENT to NAME.  The query produces the results just like I want them too, however, some of the customers have a default email address that we do not want to have in there.  For example here are my columns:
Customer Name       Customer Email           Agent Email     Name
_________________________________________________________
Bobby Joe              bobby@sales.com      default@blank.com    Jim
Sam Cole                Sam@abc.com            david@agent.com      David
Amy Jenn               amyj@xyz.com            defualt@blank.com    Ken

(3) records returned

If the agent email address matches default@blank.com then I would like it to say NULL instead I would still like it to return the 3 records just null in those columns.  

Let me know if you need anything else.  Thanks


SELECT     Telebill.dbo.Accounts.CustomerName, Telebill.dbo.Accounts.EmailAddress AS CustomerEmail, Telebill.dbo.Agents.EmailAddress AS AgentEmail, 
                      Telebill.dbo.Agents.Name
FROM         Telebill.dbo.Accounts INNER JOIN
                      Telebill.dbo.Agents ON Telebill.dbo.Accounts.Agent = Telebill.dbo.Agents.Name
WHERE     (Telebill.dbo.Accounts.EmailAddress IS NOT NULL)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of BrandonGalderisi
BrandonGalderisi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of binaryman101

ASKER

Worked great!