sql解惑之里程碑 谜题25(行转列)
来源:互联网 发布:淘宝宝马摩托车 编辑:程序博客网 时间:2024/05/21 10:24
create table servicesschedule(shop_id char(3) not null,order_nbr char(10) not null,sch_seq integer not null check(sch_seq in (1,2,3)),service_type char(2) not null,sch_date date,primary key(shop_id,order_nbr,sch_seq))insert into servicesscheduleselect '002','4155526710',1,'01',date '1994-07-16' from dual union allselect '002','4155526710',2,'01',date '1994-07-30' from dual union allselect '002','4155526710',3,'01',date '1994-10-01' from dual union allselect '002','4155526711',1,'01',date '1994-07-16' from dual union allselect '002','4155526711',2,'01',date '1994-07-30' from dual union allselect '002','4155526711',3,'01',null from dual;select order_nbr, "1" as proc, "2" as com, "3" as con from (select order_nbr, sch_seq, sch_date from servicesschedule) /**/ pivot(max(sch_date) for sch_seq in(1, 2, 3))
有人说这个题没看懂,抛砖引玉一下
这就是个行转列
- sql解惑之里程碑 谜题25(行转列)
- sql解惑2 谜题53 之lag
- 【SQL解惑】谜题13:教师
- 【SQL解惑】谜题14:电话
- sql解惑27之相等集合
- 【SQL解惑】谜题6:预订旅馆房间(待完善)
- SQL解惑
- SQL解惑-谜题32计算税收
- 【SQL解惑】谜题3:麻醉师谜题
- 【SQL解惑】谜题4:门禁卡
- 【SQL解惑】谜题7:跟踪投资组合
- 【SQL解惑】谜题8:调度打印机
- 【SQL解惑】谜题9:空座位
- 【SQL解惑】谜题11:工作顺序
- 【SQL解惑】谜题12:索赔状态
- 【SQL解惑】谜题18:广告信件
- 【SQL解惑】谜题19:销售冠军
- 【SQL解惑】谜题20:测验结果
- 面试题31:数组中的最小绝对值
- modprobe:FATAL:module "xxx" not found
- C# Enum设计和使用的相关技巧
- 如何在Android手机中开发QQ账户登陆功能的应用
- powercenter 工作流报错
- sql解惑之里程碑 谜题25(行转列)
- JAVA学习五:面向对象
- wifi笔记_scan
- ubuntu使用中一系列问题解决........
- sql解惑27之相等集合
- Java 中的进程与线程
- unity相关注意事项
- 虚方法的调用是怎么实现的(单继承VS多继承)
- 访问vector中的数据