现有一时间表
TIME         TIME1      TIME2
----------   --------   --------
2009-01-11   08:00:00   09:50:00
2009-01-11   08:00:00   09:50:00
2009-01-11   08:00:00   09:50:00
2009-01-11   10:00:00   12:00:00
2009-01-11   10:00:00   12:00:00
2009-01-11   10:00:00   12:00:00
2009-01-11   14:00:00   15:50:00
2009-01-11   14:00:00   15:50:00
2009-01-11   14:00:00   15:50:00我想实现的结果就是TIME         TIME1      TIME2
----------   --------   --------
2009-01-11   08:00:00   09:50:00
2009-01-11   10:00:00   12:00:00
2009-01-11   14:00:00   15:50:00
我现在的做法是select distinct to_char(e_datetime1,'yyyy-mm-dd') Time,
to_char(e_datetime1,'hh24:mi:ss')Time1,to_char(e_datetime2,'hh24:mi:ss') Time2 
from exam_info我对Distinct的用法还不是很懂,我觉得Distinct只是对单列进行约束不重复,如果是这样那么我上面的做法就不能达到要求,还是会显示开始的9条记录。
请大侠帮帮忙了,不胜感激....

解决方案 »

  1.   

    select distinct TIME,TIME1,TIME2 from yourTable;
      

  2.   


    --DISTINCT只取重复记录中的一条
    SELECT DISTINCT TIME, TIME1,TIME2   FROM YOURTABLE
    --你的做法是正确的,只不过没必要用TO_CHAR了~
      

  3.   

    select distinct to_char(e_datetime1,'yyyy-mm-dd') Time, 
    to_char(e_datetime1,'hh24:mi:ss')Time1,to_char(e_datetime2,'hh24:mi:ss') Time2 
    from exam_info 
    --显示3条记录select distinct TIME,TIME1,TIME2 from yourTable; 
    --显示3条记录在我这里1个语句执行都是显示3条记录啊!
    第二种一定是显示3条,如果楼主需要string类型的话,直接在程序代码里面转化好了,方便的很啊!