作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
全部,
关于转置有很多问题,但找不到最佳解决方案。因此发布另一个移置问题
我的数据是这种格式
> Customer| Status_A|Status_B|Status_C
> 111|New | Null|New
> 222|Old | Old |New
> 333|Null| New |New
>Customer Parameter Status
>111 A New
>111 B Null
>111 C New
>222 A Old
>222 B Old
>222 C New
>333 A Null
>333 B New
>333 C New
最佳答案
最简单的方法是使用巨大的union all
:
select customer, 'A' as parameter, status_a as status from t where status_a is not null union all
select customer, 'B' as parameter, status_b from t where status_b is not null union all
. . .
cross join
:
select t.customer, p.parameter,
(case p.parameter
where 'a' then status_a
where 'b' then status_b
. . .
end) as status
from t cross join
(select 'a' as parameter union all
select 'b' union all
. . .
) p;
NULL
,请使其成为子查询并使用
where status is not NULL
。
关于sql - 在Hive中转置许多列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34265721/
我已经在 jQuery transit 中加载了,我确定我是在加载 jQuery 之后才做的,但我仍然得到这个错误: 我查看了 Chrome 中的资源面板,在 jQuery 之后加载了 jQuery
我目前收到一个字符串,例如 Hello there my\r\nName is\r\nJohn Smith\r\nand\r\nstuff 我想将每一行放在一个新列表项...例如: 期望的结果(带有单
我正在尝试使用 MapKit 路线请求获取两个坐标之间的交通路线。 当我切换到其他(非 Transit)类型时,下面的代码可以工作,但是当我切换到 Transit 时,它会抛出一个错误,这个错误在 A
我是一名优秀的程序员,十分优秀!