Solved

need select statement

Posted on 2007-04-09
4
147 Views
Last Modified: 2010-03-19
how do I modify this sql select statement to include some if/then logic:
SELECT DISTINCT EMAIL FROM  tblBLAH WHERE division_name=@division_name and mgr_email=@mgr_email

I want to add to this that if @division_name is 'unknown' then we need the filter to be where division_name is null...
0
Comment
Question by:acdagirl
[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
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18876839
SELECT DISTINCT EMAIL
FROM  tblBLAH
WHERE ( division_name=@division_name OR @division_name =  'unknown'  )
AND mgr_email=@mgr_email
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18876842
sorry, a small correction:

SELECT DISTINCT EMAIL
FROM  tblBLAH
WHERE (   ( division_name=@division_name AND @division_name <> 'unknown'  )
       OR (division_name IS NULL AND @division_name = 'unknown'  )
      )
AND mgr_email=@mgr_email
0
 

Author Comment

by:acdagirl
ID: 18876846
no, that's not what I want. it's *if* the parameter @division_name comes in as 'unknown' then select division_name is null
0
 

Author Comment

by:acdagirl
ID: 18876853
ok, I'll try the second one
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

751 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