一个表中有一列dateofjoining表示员工参加工作的时间,如何查询到目前为止已有两年工作经验的员工?
我刚接触ORACLE 不太懂 希望高手能帮忙~谢谢

解决方案 »

  1.   


    select * from tb where (sysdate-dateofjoining)/365>=2;-- or
    select * from tb where extract(year from (sysdate-dateofjoining) year to month)>=2;
      

  2.   

    select * from table where to_char(sysdate,'yyyy') - to_char(dateofjoining,'yyyy') >=2;
      

  3.   

    小弟弱弱的感觉,只是弱弱的感觉,
    第一个 除 356 不是很严谨
    第二个 还是写出如下清晰
    select * from tb where extract(year from sysdate)-extract(year from dateofjoining)>=2;
    学习学习~
      

  4.   

    请问3楼,如果dateofjoining为2009-12-20,那到今天为止还未满2年吧,那你的语句还正确吗?
      

  5.   


    trunc(入职时间+interval '2' year)<=trunc(sysdate)
      

  6.   

    select * from tab where sysdate > to_char(dateofjoining,'yyyy')+2 ||'-'|| to_char(dateofjoining,'mm-dd hh24:mi:ss')
      

  7.   

    select * from 一个表 where dateofjoining>ADD_MONTHS(sysdate,-24)-1;