select to_char(t1.timestamp,'hh24:mi') timestamp, t1.value, t1.key_num
from pmis.hb_ems_fh t1,pmis.puer_ems_registab t2 
where to_char(timestamp,'yyyy-mm-dd')='2004-05-01' 
and t1.key_num=t2.key_num and t2.SFXS='1' 
order by  t1.timestamp, t2.xh

解决方案 »

  1.   

    to_char是自己写得函数?不是MSSQL 得语法?
    select to_Char(T1.timestamp,'hh24:mi') timestamp,
           t1.value,
           t1.key_num
    from   pmis.hb_ems_fh t1 left join pmis.puer_ems_registab t2 on t1.key_num=t2.key_num and t2.sfxs='1'
    where to_char(timestamp,'yyyy-mm-dd')='2004-05-01'
    order by t1.timestamp,t2.xh
      

  2.   

    to_char是sql里面的啊!
    我在PLSQL里面使用很方便的。
      

  3.   

    t2.sfxs='1'
    我发现这个条件没有起作用啊!
    打上括号也没用!
    请问怎么回事?
      

  4.   

    select to_char(t1.timestamp,'hh24:mi') timestamp, t1.value, t1.key_num
    from pmis.hb_ems_fh t1,pmis.puer_ems_registab t2 
    where timestamp>to_date('2004-05-01' ,'yyyy-mm-dd') and
          timestamp<to_date('2004-05-01' ,'yyyy-mm-dd')+1 and 
    and t1.key_num=t2.key_num and t2.SFXS='1' 
    order by  t1.timestamp, t2.xh如果还慢那就只有把timestamp加为索引了。记住:to_date要比to_char快
      

  5.   

    谢谢ryuxy(水鸟(很水的菜鸟)) ,你的程序却是运行很快!:)帮我解决了棘手的问题!
     S.F.(CSDN:896410000) 的程序也比我从前的代码快了30%左右,特此感谢!