行转列pivot -- 简单的实例 to 动态拼接行转列

一、orcale简单行转列

with temp as (
select distinct r.id               rid,
                r.level_no         levelno,
                r.type_name        rname,
                c.id               cid,
                brc.is_required    isrequired
  from b_bid_role_certificate brc
  left join c_bid_partner_role r on r.id = brc.bid_partner_role_id
  left join c_certificate c on c.id = brc.certificate_id
)
select * from temp  pivot (max(temp.isrequired) for cid in(69721041,69721042,69721043,69721044));

执行结果:

行转列pivot -- 简单的实例 to 动态拼接行转列_第1张图片

二,变成动态的行转列

Java动态拼接例子

你可能感兴趣的:(orcale)