[英]Toad for Oracle- Reshape Wide to Long
I am trying to transpose a data set from wide to long. 我正在尝试将数据集从宽到长进行转置。 Ive done this is SAS but am new to this.
我已经做到了这是SAS,但这是新手。 Ideally I want one unique row per ID and code.
理想情况下,我想要每个ID和代码一个唯一的行。 Not sure if it can be done in one step or multiple, either way would be fine with me.
不知道是否可以一步或多次完成,无论哪种方式对我来说都很好。 My data looks something like this.
我的数据看起来像这样。
ID code1 code2 code3
1 abc def ghi
1 abc xyz def
2 zyx abc mno
AND I want it to look like 我希望它看起来像
ID Code_concat
1 abc
1 def
1 ghi
1 xyz
2 zyx
2 abc
2 mno
Any advice would be greatly appreciated, thanks! 任何建议将不胜感激,谢谢!
The simplest method given that you want to remove duplicates is union
: 如果要删除重复项,最简单的方法是
union
:
select id, code1 as code_concat from t union
select id, code2 as code_concat from t union
select id, code3 as code_concat from t;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.