zoukankan      html  css  js  c++  java
  • X sql解惑 25 里程碑问题 答案

    sql解惑 25 里程碑问题 答案

    create
    table servicesschedule( shop_id char(3) not null, order_nbr char(10) not null, sch_seq number 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)); drop table sch_seq; create table sch_seq_desc( sch_seq number not null, sch_desc varchar2(20) ); insert into sch_seq_desc values(1,'processed'); insert into sch_seq_desc values(2,'completed'); insert into sch_seq_desc values(3,'confirmed'); insert into servicesschedule values('002','4155526710',1,'01',date'1994-07-16'); insert into servicesschedule values('002','4155526710',2,'01',date'1994-07-30'); insert into servicesschedule values('002','4155526710',3,'01',date'1994-10-01'); insert into servicesschedule values('002','4155526711',1,'01',date'1994-07-16'); insert into servicesschedule values('002','4155526711',2,'01',date'1994-07-30'); insert into servicesschedule values('002','4155526711',3,'01',null); select * from sch_seq_desc; select * from servicesschedule; select a.order_nbr, min(case when sch_desc = 'processed' then sch_date end) as processed, min(case when sch_desc = 'completed' then sch_date end) as completed, min(case when sch_desc = 'confirmed' then sch_date end) as confirmed from servicesschedule a,sch_seq_desc b where a.sch_seq=b.sch_seq and service_type= '01' group by order_nbr ; ============================================================================================== ============================================================================================== SQL> select * from servicesschedule; SHOP_I ORDER_NBR SCH_SEQ SERV SCH_DATE ------ -------------------- ---------- ---- ------------ 002 4155526710 1 01 16-JUL-94 002 4155526710 2 01 30-JUL-94 002 4155526710 3 01 01-OCT-94 002 4155526711 1 01 16-JUL-94 002 4155526711 2 01 30-JUL-94 002 4155526711 3 01 6 rows selected. select * from sch_seq_desc; SCH_SEQ SCH_DESC ---------- ---------------------------------------- 1 processed 2 completed 3 confirmed select a.order_nbr, min(case when sch_desc = 'processed' then sch_date end) as processed, min(case when sch_desc = 'completed' then sch_date end) as completed, min(case when sch_desc = 'confirmed' then sch_date end) as confirmed from servicesschedule a,sch_seq_desc b where a.sch_seq=b.sch_seq and service_type= '01' group by order_nbr ; ORDER_NBR PROCESSED COMPLETED CONFIRMED -------------------- ------------ ------------ ------------ 4155526710 16-JUL-94 30-JUL-94 01-OCT-94 4155526711 16-JUL-94 30-JUL-94
  • 相关阅读:
    (C/C++)区别:数组与指针,指针与引用
    C++中数组名和指针的区别联系
    C++引用的用处
    C++编写DLL动态链接库的步骤与实现方法
    C++_编写动态链接库
    C++ 模板
    C++ 信号处理
    C++ 多线程
    js事件冒泡
    js事件委托
  • 原文地址:https://www.cnblogs.com/chendian0/p/11434350.html
Copyright © 2011-2022 走看看