这种条件的sql查询怎么实现?

图片说明

怎么将表a的数据像表b这样查出来??谢谢!!

能实现,你百度 oracle行转列 就能查到

用我的用户表来给你做个相关的sql mysql数据库
select a.id as '编号',b.*,case when b.column_name='id' then a.id WHEN b.column_name='type' then a.type when b.column_name='user_name' then a.user_name end
from user a,(select column_name from information_schema.columns where table_schema='数据库名' and table_name='user') b where b.column_name in ('id','type','user_name')

CREATE table test_a
(id varchar(20),length int,wide int,high int)
insert into test_a values('1',2,3,4);

select * from test_a

-- 转换
select 
id as 编号,
(case attr
    when 'LENGTH' then '长'
    when  'WIDE' then '宽'
    when  'HIGH' then '高'
    else null end) as  属性,
 value as 值 from 
test_a
unpivot (value for attr in (length, wide, high) )