SELECT one column if the other is null

后端 未结 4 1924
星月不相逢
星月不相逢 2020-12-29 18:03

I want to select a2.date if it\'s there, but if it\'s NULL I want to select a1.date (a2 is being left-joined). This:

4条回答
  •  情深已故
    2020-12-29 18:48

    Check out the COALESCE function.

    Takes a variable number of arguments and returns the first non-null one. It works fine with joins.

提交回复
热议问题