选择列,如果空白从另一个选择 [英] Select column, if blank select from another

查看:27
本文介绍了选择列,如果空白从另一个选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检测一个字段是否为空(非空)然后选择另一个字段?

How does one detect whether a field is blank (not null) and then select another field if it is?

我真正需要的是一个 IsBlank 函数,它的工作方式与 IsNull 相同,但带有空格.

What I really need is a IsBlank function that works the same as IsNull but with with blanks.

REPLACE 不适用于空格,COALESCE 仅适用于 NULL.

REPLACE doesn't work with blanks, COALESCE only works with NULLS.

推荐答案

如何结合 COALESCE 和 NULLIF.

How about combining COALESCE and NULLIF.

SELECT COALESCE(NULLIF(SomeColumn,''), ReplacementColumn)
FROM SomeTable

这篇关于选择列,如果空白从另一个选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆