I have a query that is returning the exchange rate value set up in our system. Not every order will have an exchange rate (currate.currentrate) so it is returning null values.
Can I get it to return 1 instead of null?
Something like an if statement maybe:
if isnull(currate.currentrate) then 1 else currate.currentrate
Here is my query below. I greatly appreciate all your help!
SELECT orderhed.ordernum, orderhed.orderdate, currrate.currencycode, currrate.currentrate
FROM orderhed LEFT OUTER JOIN
currrate ON orderhed.company = currrate.company AND orderhed.orderdate = currrate.effectivedate
try like below...
You can use
COALESCE
:Or even
IsNull()
:Here is an article to help decide between
COALESCE
andIsNull
:http://www.mssqltips.com/sqlservertip/2689/deciding-between-coalesce-and-isnull-in-sql-server/
a) If you want 0 when value is null
b) If you want 0 when value is null and otherwise 1
is less verbose than the winning answer and does the same thing
https://msdn.microsoft.com/en-us/library/ms184325.aspx
You can use a
CASE
statement.