SQL if statement
I want to be able to write:
IF PROV_ID = PROVIDER NOT ON FILE or blank then 开发者_JAVA百科use BILLING_PROV
ELSE USE PROV_ID
Billing_prov
is a column name, so I want to return that value.
SELECT
CASE WHEN (PROV_ID = [PROVIDER NOT ON FILE or blank])
THEN BILLING_PROV
ELSE PROV_ID
END
FROM
...
I'm making an assumption that "not on file or blank" means null
SELECT COALESCE(PROV_ID, BILLING_PROV) as Whatever
FROM ...
精彩评论