Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

need select statement

Posted on 2007-04-09
4
Medium Priority
?
152 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

670 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