开发者

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 ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜