从生成的查询表中获取最后一行
从生成的查询表中获取最后一行
大家好,我编写了一个查询,可以在一段时间范围内获取员工的进出时间。由于我的表中有很多进出时间,所以我想根据时间戳只获取最后一个进或出时间,以下是查询语句:\n
select fullname,direction,to_char(((TO_DATE('19700101','yyyymmdd') + (tstamp/24/60/60) + 6/24)), 'dd-mm-yyyy hh12:mi:ss PM') as Time, gate,lane,employment.employeeid,NATIONALID,departmentname,designation.designationname from eofficeuat.entrylog_cpa join eofficeuat.employee on entrylog_cpa.hrrecordid=employee.hrrecordid join eofficeuat.employment on employee.hrrecordid=employment.hrrecordid join eofficeuat.designation on employment.designationid=designation.designationid join eofficeuat.department on employment.departmentid=department.departmentid where department.departmentname = 'SECURITY' and tstamp >= 1568764800 and tstamp < (select (sysdate - date '1970-01-01') * 86400000 from dual) /*and tstamp in (select max(tstamp) from eofficeuat.entrylog_cpa)*/ /*and rownum >= (select count(tstamp) from eofficeuat.entrylog_cpa)*/ and fullname='A.K.M.TOWHID SARKER' order by fullname asc;
\n这个查询会给出以下结果:\n
full name direction time --------- --------- ---- A.K.M.TOWHID SARKER out 18-09-2019 01:41:35 PM A.K.M.TOWHID SARKER out 18-09-2019 01:29:08 PM
\n但是我只想要这个结果中的最后一行,请问怎么做呢?