如何快速查询  没有刻录(Burned=0)、排在最前面(按ID排序)的数据大小之和(sum(size))小于或等于光盘容量的所有记录,实际上就是查询表T1中,字段Burned=0、字段Vol和值 <=640   按字段ID顺序排在最前面的所有记录.
比如人员表T1: Name         Sex            Age                  Burned          Vol        ID cs            m             20                     0             300         1 
ad            m             22                     0             150         2 
ba            f             22                     1             150         3 
a             f             21                     1             120         4 
aw            f             23                     0             120         5 
ad            f             22                     0             100         6 
asw           f             23                     0             60          7
ka            m             24                     0             140         8
...... Burned   0:   未刻,   1:   已刻       要求快速查出,没有刻录的且排在最前的,Vol的和值 <=640的记录
如果少查一条记录,总Vol就太小,浪费光盘,如果多查一条记录, Vol和值就超出640M,无法刻录 例如上表,应该是 
Name         Sex            Age                  Burned          Vol        ID cs            m             20                     0             300         1 
ad            m             22                     0             150         2 
aw            f             23                     0             120         5  

解决方案 »

  1.   

    看来是知道的人不多了。自己再up up
      

  2.   

    或者把它放到SQL版,这种问题他们都答了N遍了
    大概就是
    select *
    from 表 A
    where not exists
    (select 1 from 表 where id=a.id-1 and burned=0 having sum()<640)大概的思路..
    先回家喽....
      

  3.   

    select T1.Name,T1.ID,T1.Sex,T1.Age,T1.Burned,T1.Vol from 
      T1,(select Name,Max(Vol) as Vol from T1 Group by Name) a where 
        T1.Name=a.Name and
        T1.Vol=a.Vol and
        T1.Name in (select Name from T1 where Burned=0 Group by Name Having Sum(Vol)<=640)
      Order by T1.ID