select *
from table
group by a,b,c
order by a,b,c
现在不单单是看看查询结果,把select出来的结果放到一个二维数组里。我现在要把不同的group输出到不同的excel sheet,那么怎么区分group呢?我是指通过循环比较数组里的值。

解决方案 »

  1.   

    变成两步查询:

    set rs1 = cnn.execute("select distinct a,b,c from table order by a,b,c")2 
    do until rs1.eof
    set rs2 = cnn.execute("select * form table where a=" & rs1!a & " and b=" & rs1!b & " and c=" & rs1!c
    ......
    rs1.movenext
    loop
      

  2.   

    你的意思好像有点模糊,是不是要求这样
    入学生的分数
    a->表示学生的分数级别,如A、B、C
    b->表示学生的分数次级别,如A1,A2,A3
    c->表示学生的实际分数,范围在0->100
    实际上,你在查询的是否已经可以按顺序将需要的数据查出来了,为什么还要循环呢?
      

  3.   

    dim rst as new adodb.recordset
    dim a as string,b as string,c as string
    rst.open "select * from table group by a,b,c order by a,b,c",cnn,3,1
    a = rst!a & "1"
    b = rst!b & "1"
    c = rst!c & "1"
    do while not rst.eof 
        if a <> rst!a or b <> rst!b or c <> rst!c then
            '写入新的sheet
        else
            '写入刚才写入的sheet
        end if
        rst.movenext
        a = rst!a
        b = rst!b
        c = rst!c
    loop
    rst.close