难倒一片大神的sql有关问题

难倒一片大神的sql问题
有a,b两表,均有id,date字段,a表保存了完整的数列seq,b表描述了a表某段数列间的数据信息(seq_start,seq_end,seq_val),要求写一view生成一张根据b表描述标记a表的完整表,且数据不能有冗余

a表:
id    date     seq
1     2012/1/1 1
1     2012/1/1 2
1     2012/1/1 3
1     2012/1/2 1
1     2012/1/2 2
1     2012/1/2 3
2     2012/1/1 1
2     2012/1/1 2
...

b表:
id    date      seq_start    seq_end    seq_val
1     2012/1/1  2            3          'val1'
1     2012/1/2  1            2          'val2'
2     2012/1/1  1            2          'val3'
...
完成表: 
id    date      seq   seq_val
1     2012/1/1  1
1     2012/1/1  2     'val1'
1     2012/1/1  3     'val1'
1     2012/1/2  1     'val2'
1     2012/1/2  2     'val2'
1     2012/1/2  3
2     2012/1/1  1     'val3'
2     2012/1/1  2     'val3'
...
这个问题我自己就搞了一周,写了个用left join的view,on条件过于复杂结果慢的没法用,问了好多大神都被难倒的稀里哗啦的,要是****上没人搞那我就只能用存储过程自己整了

------解决方案--------------------
select a.*,b.seq_val
  from a a
  left join b b on a.id = b.id
               and a.date = b.date
               and a.seq >= b.seq_start
               and a.seq <= b.seq_end;

------解决方案--------------------
引用:
Quote: 引用:

select a.*,b.seq_val
  from a a
  left join b b on a.id = b.id
               and a.date = b.date
               and a.seq >= b.seq_start
               and a.seq <= b.seq_end;

我就这么写的,问题是,你考虑过这语句效率问题么,我贴出来实际的代码你感受下

select e.*,f.completion_id,f.completion_name,f.completion_number,f.top_md,f.bottom_md
from (
select c.jh,d.create_date,c.yczmc,c.xch,d.cds,c.syds,c.syhd,c.yxhd,c.yxstl,c.dcjsjg,c.skqk
from daa05@dzcxyh c,(
select jh,create_date,
count(completion_id) cds
from (
select a.well_desc jh,b.completion_id,
to_date(to_char(b.create_date,'yyyy-MM-dd'),'yyyy-MM-dd') create_date
from cd_well_source@a2 a,cd_completion_t@a2 b
where b.well_id=a.well_id
)
group by jh,create_date
) d
where c.jh=d.jh
) e left join (
select a.well_desc jh,
to_date(to_char(b.create_date,'yyyy-MM-dd'),'yyyy-MM-dd') create_date,
b.completion_id,b.completion_name,b.completion_number,
nvl(b.top_md,0) top_md,
nvl(b.bottom_md,0) bottom_md
from cd_well_source@a2 a,cd_completion_t@a2 b
where b.well_id=a.well_id
order by a.well_desc
) f
on e.jh=f.jh and e.create_date=f.create_date and (f.top_md=0 or f.bottom_md=0 or (f.top_md<=e.syds and f.bottom_md>=e.syds+e.syhd));
这个问题根本就不是left jion on的问题, 也不是他们回答的有问题,而是你自己问的有问题,通过dblink的视图关联的结果集和你描述的一张表是一个概念么