oracle sql

来源:互联网 发布:荆门市网络作文大赛 编辑:程序博客网 时间:2024/05/16 18:13
select * from(
   select a.*
   from attendance a,period p,shift_period sp,user_shift us
   where a.userId=#userId# and us.userId=a.userId and p.periodId=sp.periodId and us.shiftId=sp.shiftId
    and to_char(attendanceTime,'yyyy-MM-dd')=to_char(sysdate, 'yyyy-mm-dd')
    and (to_date(to_char(attendanceTime,'hh24:mi'),'hh24:mi') between to_date(p.checkInTime1,'hh24:mi') and to_date(p.checkInTime2,'hh24:mi')) order by a.attendanceTime asc)
   
  where rownum < 2
  order by rownum asc