Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

case statement to evaluate null values syntax

Status
Not open for further replies.

staceyn

Technical User
Nov 19, 2004
107
US
Hello,
I am trying to figure out how to write the following query in SQL if anyone can help

Use field A if not blank othrewise use field B, if field B is blank print "N/A"

Thanks
 
Code:
SELECT COALESCE(NULLIF(FieldA,''), NULLIF(FieldB,''), 'N/A')
FROM YourTable
th fieldA or FieldB can not be empty, just NULL, then there is no need to use NULLIF() function.

Borislav Borissov
VFP9 SP2, SQL Server
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top