表a 
字段 
id 
name a表数据 
id name 
1,‘张三’ 
2, ‘李四’ 
------------------------- 
表 b 
字段 
id, 
a_id reference a.id , --外键引用a表的id c_id reference c.id, -----外键引用c表的id 
value, 
b_date , 数据 
id a_id c_id values b_date 
1, 1 ,1,2000,'1979-2月-21' 
2, 1 ,2,1000,'1979-2月-21' 
3, 2 ,1,2000,'1979-2月-21' 
4, 2 ,2,2000,'1979-2月-21' 
5, 1 ,1,2000,'1980-1月-21' 
6, 2 ,1,1000,'1980-1月-21' 
------------------------------------------ 
表c 
字段 id 
name 数据 
id name 
1,basemoney 
2,reward 
-------------------------------------------- 
实现 ,按一个人的月份横排,没值得用空代替 
a.id a.name b.value b.value b.b_date 
1 张三 2000 1000 1979-2-21 
1 张三 2000 null 1980-1月-21 
2 李四 2000 2000 1979-2-21 
2 李四 1000 null 1980-1月-21 

解决方案 »

  1.   

    你……?????!!!!!!
    建视图的话,用
    create or replace view aaa as 
    select b.a_id,a.name,sum(decode(c_id,1,b.value)) value1,
    sum(decode(c_id,2,b.value)) value2,b_date from a,b
    where a.id = b.a_id group by b.a_id,a.name,b.b_date;
      

  2.   

    create view v_name id,name,value,b_date as select aa.id,aa.name,decode(bb.value,'',null,bb.value),bb.b_date from a aa,b bb where aa.id = bb.id order by bb.b_date;
      

  3.   

    忘记括号了 (id,name,value,b_date)