select a.pk,b.pk,c.pk,d.pk,e.pk
from yourtable a,yourtable b,yourtable c,yourtable d,yourtable e
where a.rowid<b.rowid and b.rowid<c.rowid and c.rowid<d.rowid and d.rowid<e.rowid
 and (a.fs+b.fs+c.fs+d.fs+e.fs)=20;其中pk是指表中的主键。

解决方案 »

  1.   

    用分析函数做了一个小时也没做出来。
    只好同意楼上的,采用自关系:
    select a.pk,b.pk,c.pk,d.pk,e.pk
     from yourtable a,yourtable b,yourtable c,yourtable d,yourtable e
     where e.rowid=a.rowid+4 and e.rowid=b.rowid+3 and e.rowid=c.rowid+2
     and e.rowid=d.rowid+1
     and (a.fs+b.fs+c.fs+d.fs+e.fs)=20 order by e.pk;
      

  2.   

    我还没有看懂呢:
    where a.rowid<b.rowid and b.rowid<c.rowid and c.rowid<d.rowid and d.rowid<e.rowid
    为什么要
    a.rowid<b.rowid b.rowid<c.rowid 等这样的关系呢?