在SQL中的下一行中移位行

编程入门 行业动态 更新时间:2024-10-11 03:20:23
本文介绍了在SQL中的下一行中移位行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我有一张桌子 -

Hello All, I have a table like -

Name Mobile 1 Sachin 8010023456 2 Kamal 9935463456

我们必须像以下一样返回 -

We have to return just like as -

Name Mobile 1 Blank Blank 2 Sachin 8010023456 3 Kamal 9935463456

推荐答案

请阅读我的评论。 我不确定你想达到什么,但看看示例: Please, read my comment. I'm not sure what you want to achieve, but have a look at example: SELECT NULL AS [Name], NULL AS [Mobile] UNION ALL SELECT [Name], [Mobile] FROM TableName

如果您只想将第一条记录输出为空白,请尝试此操作。将@t替换为您的表名。 If you just want a output with 1st record as blank try this. Replace @t with your table name. select ROW_NUMBER()over(order by name), name,phone from ( select '' as name,'' as phone union all select name,phone from @t ) p

你应该从表中查询并复制到另一个表并将其命名为 you should query from table and copy to another table and raname it

更多推荐

在SQL中的下一行中移位行

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

发布评论

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

>www.elefans.com

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