COALESCE or CASE more efficient and/or standard

前端 未结 2 1875
暖寄归人
暖寄归人 2021-01-19 13:31

In terms of x compared to y.

  • Does x comply with sql standards better? [apologies if subjective]
  • Is x more efficient than y?
  • Or are these
相关标签:
2条回答
  • 2021-01-19 13:38

    COALESCE is essentially a shorthanded CASE statement.

    Both are exactly the same.

    There is also ISNULL in SQL Server (differs in other DBMSs), but that's actually a non-standard feature and is actually more limited that COALESCE.

    0 讨论(0)
  • 2021-01-19 14:01

    In this case I would use COALESCE ( which provides more levels than ISNULL) rather than the CASE stement.

    The CASE statement seems a bit bulky here, seeing as you are only checking for NULLs anyway.

    0 讨论(0)
提交回复
热议问题