Sql server结果集

编程入门 行业动态 更新时间:2024-10-13 22:21:43
本文介绍了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结果集

本文发布于:2023-11-22 01:51:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1615510.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Sql   server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!