本文介绍了Sql server结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有如下表格 name a b c gopi NULL 6 5 Ram NULL 5 NULL Balaji NULL NULL 3 和我需要输出如下 名称asd gopi 6 Ram 5 Balaji 3 我用过交叉申请,但我没有确切的输出。有人可以帮忙吗? 我尝试了什么: text
Hi, I have table like below name a b c gopi NULL 6 5 Ram NULL 5 NULL Balaji NULL NULL 3 And i need output like below name asd gopi 6 Ram 5 Balaji 3 I have used cross apply but i didn't exact output. can anyone help? What I have tried: text
推荐答案您可以使用COALESCE()函数。它将返回您传入的值列表中的第一个非null值。 例如: You can use the COALESCE() function. It will return the first non null value in the list of values you pass in. For example: SELECT name, COALESCE(a,b,c) AS someField FROM table
如果不为空将返回a,如果a为null,则返回b,如果不为null,等等。
will return a if it is not null and if a is null it will return b if not null, etc.
更多推荐
Sql server结果集
发布评论