如何将列转换为行..? [英] how to convert column into rows..?

查看:86
本文介绍了如何将列转换为行..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

column1 column2 column3 column4

MR00386 ASM0092 MR00391 MR00392



i想要这样的值



column1

MR00386

ASM0092

MR00391

MR00392

column1 column2 column3 column4
MR00386 ASM0092 MR00391 MR00392

i want values like this

column1
MR00386
ASM0092
MR00391
MR00392

推荐答案

使用 UNPIVOT [< a href =https://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx\"target =_ blanktitle =New Window> ^ ] - 它位于页面底部。
Use UNPIVOT[^] - it's at the bottom of the page.


你可以使用UNION。



你可以按照它的标准选择每个值UNION它使用新标准查询同一个表。



请记住:当您创建UNION时,为每个查询返回的所有列必须是相同的类型。



如果。 。 。你需要允许重复的结果然后你可能需要UNION ALL。



要小心这个!
You can use "UNION".

You select each value by it's criteria and UNION it with a query to the same table with the new criteria.

Just remember: when you create a UNION, all columns returned for each of the queries must be of the same type.

IF . . . you need to allow duplicate results then you may require UNION ALL.

Be cautious about this!


这篇关于如何将列转换为行..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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