I have not used access before but I have to convert an access query into SQL so I can write a report in crystal.
The query currently uses the IFF function in its select statement which appears to determine what value will be returned depending on the table's value for a particular column.
So for instance if the value is "CR" it should be returned as "credit" and if it's "NCR" it should be returned as "non-credit"
Can I do something like this in SQL?
Use a CASE expression.
CASE WHEN SomeColumn = 'CR' THEN 'credit'
WHEN SomeColumn = 'NCR' THEN 'non-credit'
END
You can use the CASE statement:
SELECT CASE WHEN [value] = 'CR' THEN 'Credit' WHEN [Value] = 'NCR' THEN 'non-credit' END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With