现在有张表 schedule包含下面的字段和信息
cid,  tid,  classtime,  classno
001  t0001   time1       no1
001  t0001   time2       no1
002  t0002   time1       no2
002  t0002   time2       no2向提取出
001  t0001   
002  t0002   sql语句怎么查啊,谢谢各位!  

解决方案 »

  1.   


    select distinct cid,tid from tb 
    ???
      

  2.   

    --这样??
    select distinct cid,tid from schedule group by cid 
      

  3.   

    SELECT CID,TID FROM schedule T WHERE NOT EXISTS(SELECT 1 FROM schedule WHERE CID=T.CID TID=T.TID
    AND classtime>T.classtime )
      

  4.   


    select id,tid  from schedule group by cid,tid 
      

  5.   

    --还是这样??
    select cid,tid from schedule a where not exists(select 1 from a where cid=a.cid TID=T.TID and classtime>a.classtime )
      

  6.   

    写错了
    select cid,tid from schedule a where not exists(select 1 from a where cid=a.cid and classtime>a.classtime )
      

  7.   

    1.
    SELECT DISTINCT cid,tid 
    FROM schedule
    ORDER BY cid 2.
    SELECT cid,tid 
    FROM schedule
    GROUP BY cid,tid
    ORDER BY cid 
      

  8.   

    8楼,第二个
    SELECT cid,tid 
    FROM schedule
    GROUP BY cid,tid
    ORDER BY cid

    SELECT cid,tid 
    FROM schedule
    GROUP BY cid,tid 有什么区别吗??我觉得效果是一样的
      

  9.   

    select cid, tid from schedule  group by cid,tid 
      

  10.   

    select id,tid  from schedule group by cid,tid 
      

  11.   

    select distinct cid,tid from schedule 
      

  12.   

    select cid,tid from table group by cid,tid
      

  13.   

    select cid,tid from table group by cid,tid
      

  14.   


    select id,tid  from schedule group by cid,tid 或者select distinct cid,tid from table
      

  15.   

    SELECT CID,TID FROM schedule T WHERE NOT EXISTS(SELECT 1 FROM schedule WHERE CID=T.CID TID=T.TID
    AND classtime>T.classtime )
    -------------------------------
    正解
      

  16.   

    select distinct cid,tid from tb 
      

  17.   

    select distinct cid,tid from schedule group by cid 
      

  18.   

    code=SQL]SELECT DISTINCT cid,tid 
    FROM schedule
    ORDER BY cid 
    ???
    是这样???[[/code]
      

  19.   


    SELECT DISTINCT cid,tid 
    FROM schedule 
    ORDER BY cid 
    ??? 
    是这样??
      

  20.   

    select distinct cid,tid from schedule 是最简单的!
      

  21.   


    select cid,sid from schedule  group by cid,sid
      

  22.   


    select distinct cid,tid from tb 
      

  23.   

    SELECT CID,TID FROM schedule T WHERE NOT EXISTS(SELECT 1 FROM schedule WHERE CID=T.CID TID=T.TID
    AND classtime>T.classtime )
      

  24.   

    对cid,  tid这两个字段做唯一索引.
      

  25.   


    select distinct cid,tid
    from schedule
      

  26.   

    select distinct cid,tid from schedule
      

  27.   

    select cid,tid from schedule group by cid,tid
      

  28.   


    select id,tid  from schedule group by cid,tid 
    --或者select distinct cid,tid from schedule
      

  29.   

    select distinct(cid),tid from accpbs 
      

  30.   

    select cid,tid from accpbs group by cid,tid
      

  31.   

    select id,tid  from schedule group by cid,tid 
    select distinct cid,tid from schedule感觉楼主没有把问题的所有条件说全。
      

  32.   

    select id,tid  from schedule group by cid,tid 
      

  33.   


    select distinct cid,tid from tb 
      

  34.   

    select  cid,tid from schedule group by cid,tid 
      

  35.   

    现在有张表 schedule包含下面的字段和信息 
    cid,  tid,  classtime,  classno 
    001  t0001  time1      no1 
    001  t0001  time2      no1 
    002  t0002  time1      no2 
    002  t0002  time2      no2 向提取出 
    001  t0001  
    002  t0002  sql语句怎么查啊,谢谢各
    select cid, tid from schedule
    where cid<003
      

  36.   

    select cid,tid from table group by cid,tid
      

  37.   

    你这数据是偶然的还是   你要的是不是这样select distinct cid,tid from schedule