如何将行转换为列 [英] How to convert rows to columns

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

问题描述

嗨 


我想要将行转置为列。来自Image:

我想基于frequency_band和RRH_ANY_BAND进行转置。请注意,USIDN是初始数据集中的公共值。一些USIDN有2行,有些有3行(未显示)。 


每个USDIN的输出应该有1行,它将是第一列。接下来的6列是B1,B2,B3,R1,R2,R3。因此,如果
只存在1或2行,则B3和R3可能为空或空值

解决方案


嗨 


我想将行转换为列。来自Image:

我想基于frequency_band和RRH_ANY_BAND进行转置。请注意,USIDN是初始数据集中的公共值。一些USIDN有2行,有些有3行(未显示)。 


每个USDIN的输出应该有1行,它将是第一列。接下来的6列是B1,B2,B3,R1,R2,R3。因此,如果
只存在1或2行,则B3和R3可能为空或空值


美好的一天
ayman


>>  来自图片:


1。没有图像,如果你计划发布一个


2。图片没有行和列。


您应该发布查询以创建表格并插入一些示例数据,而不是图片。


> >所有描述都没有给我们任何东西,但没有能够看到表,但一般来说,我猜你需要的是使用PIVOT


请检查本教程是否帮助您解决问题,如果没有,那么请发布缺失的信息(不是图像!)


https://docs.microsoft.com/en-us/sql/t-sql/queries /从-使用枢轴和 - 逆透视


Hi 

I would like to transpose rows to columns. From Image:
I’d like to transpose based on frequency_band and RRH_ANY_BAND. Note that USIDN is the common value in initial data set. Some USIDN have 2 rows and some with 3 rows (not shown). 

The ouput should have 1 row per USDIN and it would be first column. The next 6 columns would be B1, B2, B3, R1, R2, R3. So it's possible for B3 and R3 to be empty or nulls if only 1 or 2 rows exist

解决方案

Hi 

I would like to transpose rows to columns. From Image:
I’d like to transpose based on frequency_band and RRH_ANY_BAND. Note that USIDN is the common value in initial data set. Some USIDN have 2 rows and some with 3 rows (not shown). 

The ouput should have 1 row per USDIN and it would be first column. The next 6 columns would be B1, B2, B3, R1, R2, R3. So it's possible for B3 and R3 to be empty or nulls if only 1 or 2 rows exist

Good day ayman,

>> From Image:

1. There is no image,if you planed to post one

2. Image does not have rows and columns.

Instead of image, you should post queries to create your table and insert some sample data.

>> all the description does not give us anything without being able to see the table, but in general I am guessing that what you need is to use PIVOT

Please check if this tutorial help you solve the issue, and if not, then please post the missing information (NOT image!)

https://docs.microsoft.com/en-us/sql/t-sql/queries/from-using-pivot-and-unpivot


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

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