日期:2014-05-17  浏览次数:20923 次

现有一张表,速求能够帮我做一条oracle语句?
create table sell(

  id int not null primary key ,
 
  name varchar(100) not null,
 
  dt date not null,
 
  price decimal (10,2) not null
);




insert into sell(id, name, dt, price)
select 1, '香烟' ,to_date('2012-01-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),12.00 from dual
union 

select 2, '衣服' ,to_date('2012-03-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),240.00 from dual
union 
select 3, '手机' ,to_date('2012-04-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),1200.00 from dual
union 

select 4, '可乐' ,to_date('2012-08-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),5.00 from dual
union 
select 5, '啤酒' ,to_date('2012-01-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),10.00 from dual


/*表一
季度 消费金额
*/
  **** ****
  **** ****





/*表二
1季度 2季度 3季度 4季度
*/  
  **** **** **** ****
  **** **** **** ****

------解决方案--------------------
测试数据:
SQL code

create table sell
(
    id int not null primary KEY,  
    name varchar(100) not null,  
    dt date not null,  
    price decimal (10,2) not null
);

insert into sell(id, name, dt, price)
select 1, '香烟' ,to_date('2012-01-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),12.00 from dual
union  

select 2, '衣服' ,to_date('2012-03-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),240.00 from dual
union  
select 3, '手机' ,to_date('2012-04-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),1200.00 from dual
union  

select 4, '可乐' ,to_date('2012-08-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),5.00 from dual
union  
select 5, '啤酒' ,to_date('2012-01-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),10.00 from dual

SELECT * FROM sell;