行转列
select student.name,max(case when course.name='数学' then score end) "数学"
,max(case when course.name='语文' then score end) "语文"
,max(case when course.name='英语' then score end) "英语" from (
select '001'no,'数学' name from dual
union all
select '002', '语文' from dual
union all
select '003', '英语' from dual
)course,
(
select 'S001'no ,'小红' name from dual
union all
select 'S002','小明' from dual
) student
,(
select 'S001' studentno,'001' courseno,90 score from dual
union all
select 'S002','002',88 from dual
union all
select 'S001','003',70 from dual
)
where course.no= .courseno and student.no=.studentno
group by student.name
select student.name,max(case when course.name='数学' then score end) "数学"
,max(case when course.name='语文' then score end) "语文"
,max(case when course.name='英语' then score end) "英语" from (
select '001'no,'数学' name from dual
union all
select '002', '语文' from dual
union all
select '003', '英语' from dual
)course,
(
select 'S001'no ,'小红' name from dual
union all
select 'S002','小明' from dual
) student
,(
select 'S001' studentno,'001' courseno,90 score from dual
union all
select 'S002','002',88 from dual
union all
select 'S001','003',70 from dual
)
where course.no= .courseno and student.no=.studentno
group by student.name
解决方案 »
- oracle rac 提示虚拟主机名似乎已分配错误
- RAMN备份遇到的问题
- 关于sql
- 超有难度的sql,400分奉上!
- ORACLE FOR AIX 安装问题,急!
- 数字或值错误: 字符串缓冲区太小
- 表中纪录中最大日期的sql怎么写?
- 我在客户端 访问ORACLE时遇见ora-06401:netcmn:无效的驱动程序指示符
- 有关oracle例程开机不能自动启动的问题 在线等待... ...
- 使用oracle12c创建数据库时,出现了GRANT失败,显示口令文件缺失或禁用 有大神知道么
- 关于pga_aggregate_target和processes两个参数设置问题
- Oracle table insert data
如果第一张表里的里面的数据多了肿么搞。