读书人

现有一张表速求能够帮小弟我做一条o

发布时间: 2012-04-12 15:46:35 作者: rapoo

现有一张表,速求能够帮我做一条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 dualunion  select 2, '衣服' ,to_date('2012-03-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),240.00 from dualunion  select 3, '手机' ,to_date('2012-04-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),1200.00 from dualunion  select 4, '可乐' ,to_date('2012-08-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),5.00 from dualunion  select 5, '啤酒' ,to_date('2012-01-01 12:03:00','yyyy-MM-dd HH24:mi:ss'),10.00 from dualSELECT * FROM sell; 

读书人网 >oracle

热点推荐