Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sql  select statement with if then

Posted on 2011-02-25
3
Medium Priority
?
417 Views
Last Modified: 2012-05-11

I have a if then else statment that is a small portion of a larger statement but i cant seem to figure out syntax.  here is what i am looking for.

select (if por1.U_SIF_Vendprom = null then por1.shipdate else por1.U_SIF_Vendprom) as REQDATE from por1

0
Comment
Question by:notasgoodasyou
[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
3 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 34984501
select CASE WHEN por1.U_SIF_Vendprom IS NULL then por1.shipdate else por1.U_SIF_Vendprom END as REQDATE from por1
0
 
LVL 23

Expert Comment

by:wdosanjos
ID: 34984675
Alternatively:

select ISNULL(por1.U_SIF_Vendprom, por1.shipdate) as REQDATE from por1
0
 
LVL 41

Expert Comment

by:Sharath
ID: 34985026
Is the data type of vendprom and shipdate same? you can also try COALESCE.

select COALESCE(por1.U_SIF_Vendprom, por1.shipdate) as REQDATE from por1
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

609 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