• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 420
  • Last Modified:

Sql select statement with if then


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
notasgoodasyou
Asked:
notasgoodasyou
1 Solution
 
Patrick MatthewsCommented:
select CASE WHEN por1.U_SIF_Vendprom IS NULL then por1.shipdate else por1.U_SIF_Vendprom END as REQDATE from por1
0
 
wdosanjosCommented:
Alternatively:

select ISNULL(por1.U_SIF_Vendprom, por1.shipdate) as REQDATE from por1
0
 
SharathData EngineerCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now