如何使用 Oracle 数据透视表查询?

哈坎特

我有四列,如下所示。

在此处输入图片说明

我能得到这样的东西吗?

在此处输入图片说明

谢谢

专卖店

我会推荐条件聚合。它是一种独立于数据库的语法,比 Oracle 特定的pivot语法更灵活

select
    piece_id,
    max(case when attrb_code = 'A' then attrb_a_value end) a,
    max(case when attrb_code = 'B' then attrb_a_value end) b,
    max(case when attrb_code = 'C' then attrb_a_value end) c,
    max(case when attrb_code = 'D' then attrb_b_value end) d
from mytable
group by piece_id

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章