ORACLE 行转列 测试通过(9i)
来源:互联网 发布:sql默认值或绑定 编辑:程序博客网 时间:2024/05/13 13:26
--ORACLE 行转列 测试通过(9i)
/***************************************************************************************************
以学生成绩为例子,比较形象易懂
***********************************************************************************************************/
--1、行转列
--> --> 生成测试数据
drop table Class ;
Create table Class(Student varchar2(20),Course varchar2(20),Score number) ;
Insert into Class
(
select '张三','语文',78 from dual union all
select '张三','数学',87 from dual union all
select '张三','英语',82 from dual union all
select '张三','物理',90 from dual union all
select '李四','语文',65 from dual union all
select '李四','数学',77 from dual union all
select '李四','英语',65 from dual union all
select '李四','物理',85 from dual );
--case 方式:
select Student,sum(语文) 语文,sum(数学) 数学,sum(物理) 物理,sum(英语) 英语
from(
select Student,
case Course when '语文' then Score else 0 end as 语文,
case Course when '数学' then Score else 0 end as 数学,
case Course when '物理' then Score else 0 end as 物理,
case Course when '英语' then Score else 0 end as 英语
from Class )
group by Student;
--decode 方式:
select student,sum(decode(Course,'语文', Score,0)) as 语文,
sum(decode(Course,'数学', Score,0)) as 数学,
sum(decode(Course,'物理', Score,0)) as 物理,
sum(decode(Course,'英语', Score,0)) as 英语
from Class
group by student;
drop table Class ;
- ORACLE 行转列 测试通过(9i)
- [转]oracle------行转列(动态行转不定列)----测试通过(9i)
- C#通过webservice连接Oracle 9i数据库
- Oracle 9i&10g编程艺术 性能测试
- oracle数据库(9i)
- oracle capability i/o(压力测试数据库服务器i/o性能)
- ODI如何通过logminer技术从oracle 9i或者10g中抽取增量数据(三)
- SQL SERVER 2008 通过链接服务器(Linked Server)访问 ORACLE 9i /10g的方法 (亲测)
- SQL SERVER 2008 通过链接服务器(Linked Server)访问 ORACLE 9i /10g的方法
- SQL SERVER 2005 通过链接服务器 访问 ORACLE 9i 的快速设定方法
- php 5.1.4 通过OCI8 以及instantclient访问远程oracle 9i数据库
- 通过数据链接(Database Link),从Oracle 9i 连接 SQL Server 2000(实例)
- 通过数据链接(Database Link),从Oracle 9i 连接 SQL Server 2000
- JBoss4.0.3 + Oracle 9i (JNDI)
- Oracle 9i 的安装(图解)
- Oracle 9i 的安装(图解)
- Oracle 9i 的安装(图解)
- Oracle 9i 的安装(图解)
- 地面沉降研究综述
- Ubuntu远程访问MySQL
- 本人初次使用Ibatis操作MS SqlServer2000数据库遇到的问题
- Debian硬盘安装的几个关键设置
- 操作Excel的jxl包的使用
- ORACLE 行转列 测试通过(9i)
- [转]oracle------行转列(动态行转不定列)----测试通过(9i)
- 俞敏宏的一段话,看着激情的老俞,我哭了又哭
- 异常:Error: java.lang.IncompatibleClassChangeError: Implementing class
- 在Dreamweaver中用细线表格布局
- 膀胱炎的分类
- 低碳经济两大主线及13条分支投资机会全景扫描
- 一 java的基本类型
- 土壤中氮含量的测定分析