首页 > 代码库 > 在oracle中将某个字段的数据作为列名的查询

在oracle中将某个字段的数据作为列名的查询

原表结构

技术分享

查询语句:
select sno,sname,sum(语文) 语文,sum(数学) 数学,sum(英语) 英语 from (select sno,sname,decode(subjiect,‘语文‘,grade) 语文,decode(subjiect,‘数学‘,grade) 数学,decode(subjiect,‘英语‘,grade) 英语 from MYOBJECT)
group by sno,sname
 
查询结果
技术分享

 

在oracle中将某个字段的数据作为列名的查询

 

在oracle中将某个字段的数据作为列名的查询