表名   11111
字段:    time                           TOC
数据:   2006-4-5 0:00                    15
        2006-4-5 1:00                    15
        2006-4-5 3:00                    15
        2006-4-5 4:00                    101
        2006-4-5 6:00                    21
        2006-4-5 10:00                   8
        .............                    ...我想请教一下:   selectstr = "select distinct(TOC) from [11111]"    TOC改变时,如何把相对应的time也显示出来(只考虑TOC改变时的字段)...语句该怎么写...谢谢! 
      不知道这题值多少积分...

解决方案 »

  1.   

    select distinct TOC,time from [11111]
      

  2.   

    select * 
    from 11111 a
    where not exists(select top 1 * from 11111 where TOC=a.TOC and time>a.time)                           
      

  3.   

    两位的SQL语句我试了一下,都不能解决我的问题...可能是我的表达有误吧...我执行了一下你们的程序,结果都把time字段显示出来了...
    我的意思是:把不同的TOC显示出来...同时把不同TOC对应的time字段显示出来...谢谢两位!
    请教了其他人:得用两个SQL语句才能完成:
    select distinct(toc) from [11111] 找出 不同 toc 的数据集,然后,根据数据集中的内容, 用 select min([time]) from [11111] where ( toc='" & toc的数据集.fields(0).value & "')" ...谢谢两位!
      

  4.   

    select TOC , max(time)  from [11111] group by TOC如果对time这个列没有要求 , 你可以用上面的语句
      

  5.   

    呵呵!谢谢leo_lesley(leo)...你的正解...没想到一步就可以完成...