最近一直在用mysql数据库做云项目,有段时间没有接触oracle了,昨天有朋友叫我帮忙用oracle处理一个考勤记录的需求,我在考虑如何尽量精简实现上面花了一些时间。于是把这个实现做个总结。

需求如下:

  1. rownum为奇数的为进厂时间,偶数的为离场时间
  2. 第一个奇数行的时间被第一个偶数行相减,以此类推
  3. 将上面两步产生的时间结果集相加得出总时间作为当天考勤时间

最终能和别的表联合起来形成这样的展示:

人员

日期

工时

入厂时间

出厂时间

张三

2015/6/18

9小时30分钟

8:00:00

10:30:00

11:00:00

12:30:00

13:30:00

17:30:00

18:00:00

18:30:00

19:00:00

19:30:00

20:00:00

20:30:00

李四

..

..

要我实现的是如何把时间一列的数据拆分成为两列来显示:

原来一列是这样的:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIcAAADuCAIAAACcfoPPAAALcklEQVR4nO2dPa7yOhCGsyckCtZCQcU60qVlCUiU6FZXok5Dywao6dkBX5HY8c+MY5vEGXLekYtz4rEz9puMY8Ijqvd3dj6fP5/Pl53AOtOTWS0dCYyw6vrf/yjSSvWBybNBlbquF4xj3fZ+v+Od67ru15Xz+dypsmg6XbNFzm0nBFQpZJOpcj1U2g5Xu/Wj2bJ1faV9+HogPK+Hats8uAjN82vr/HXDzsfptzu/6eCYF/H8Nokqj2ZrBn89VMb8+f9Zw3w02+3hsLUP9rPjSRVQJeDmqOKdn9BvYZtEFW8ww4FHsw1O7qPZbpuH63U9VNumcQScRBX3Cng02+pwOKxUFWY0vii2qWl4NFuzh/6wfWNNo0pzNUPqLorrKlXhVw4vYdlmzII1IVbOUe0nUsW8MTtRvBRHrE1lbepnMDWufixhVWgl3q5afQ9TqTLcwL0onsPiNs+TsZ7KYAYjrsze15Wrsq7osI2roqJSoqxTFX8swzLhyTJUUc8I9G3R6dJMpkoXVaNEWacq3mpvScE8GTvru+3qzY71/Bq2GFWsTcpaVXnbyz2zUXNzFDEBauNDzM6j2U6oin1RBFf7JbaRaaqcleETl1ntHG3DvfJ+v5dTRcqHI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E+GBvFsbLNfZgueNnd1P+ZOikE8JWa99PTZWIqcpHmwg5yk2thiZb308NnaIXKS5sEOcpIqFi/rZYDPWaUYaWRYxLMXdqghJ2marJfzPiMnaRHsfOUTISdpgqyXoT5nkVaxqT0nqbvP00nJPQ9yksbNehnocx7i0SF42hs7kiEnaYKsl14+Iydp1uywfiInaaSsl74+Z/XAwEs8u2BHMuQkjZr10t/nHB5VO9qr9JykYT4jJ2marJcePiMnaSHsICfpFD5kvQy22K/ngJ0ASyYeZL1cZJHFA3ZCDC+GlmF4MTRDg3jKMIgnQ3vhl6QAEIxBPP4/4QYA4PuFeAAgGBAPAATiP4Do0I6EP3cjAAAAAElFTkSuQmCC" alt="" />

实现方式如下:

首先创建一个时间表(当然这里我关注的只是scan_time这个字段,其他字段不用理会):

create table CMIS_PERSON_FI_DETAIL_TB
(
detail_id NUMBER(20) not null,
scan_time DATE,
person_fk_id NUMBER(20) not null
)

其次,插入数据,插入数据之后的效果是这样的:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIcAAADuCAIAAACcfoPPAAALcklEQVR4nO2dPa7yOhCGsyckCtZCQcU60qVlCUiU6FZXok5Dywao6dkBX5HY8c+MY5vEGXLekYtz4rEz9puMY8Ijqvd3dj6fP5/Pl53AOtOTWS0dCYyw6vrf/yjSSvWBybNBlbquF4xj3fZ+v+Od67ru15Xz+dypsmg6XbNFzm0nBFQpZJOpcj1U2g5Xu/Wj2bJ1faV9+HogPK+Hats8uAjN82vr/HXDzsfptzu/6eCYF/H8Nokqj2ZrBn89VMb8+f9Zw3w02+3hsLUP9rPjSRVQJeDmqOKdn9BvYZtEFW8ww4FHsw1O7qPZbpuH63U9VNumcQScRBX3Cng02+pwOKxUFWY0vii2qWl4NFuzh/6wfWNNo0pzNUPqLorrKlXhVw4vYdlmzII1IVbOUe0nUsW8MTtRvBRHrE1lbepnMDWufixhVWgl3q5afQ9TqTLcwL0onsPiNs+TsZ7KYAYjrsze15Wrsq7osI2roqJSoqx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rFAlaJldG8focovcpGJMb/ARQ7Rz8VFJsRsTCW4yDm5yIyYvfsMXORsXOR4zOAirTxbhIuMj9m4/CtwkfNykfExe9qAi5yHi0yKmY4TXCTrQHU7ykWmxmwXcJFzcJF5MYOLnJWLTIgZXKQ5a+AiY0pJVcBFSlQFJbZAFYmlxbtImfYP336rhQ47CU0AAAAASUVORK5CYII=" alt="" />

最后编写sql进行实现,实现的sql语句如下所示:

select max(a) in_time, max(b) out_time
from (select decode(mod(rownum, 2), 1, scan_time) a,
decode(mod(rownum, 2), 0, scan_time) b,
round(rownum / 2) c
from CMIS_PERSON_FI_DETAIL_TB)
group by c
order by c;

运行sql,得到了想要的效果,如下所示:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAARQAAACECAIAAADeA0PZAAANR0lEQVR4nO1dPZLzLBPUnVzlwGdx4MjncObUR3iqHG590Vel2IlTX0Dx5nsDv4EkNMCAAAkEqLsmWIsfDdPbAsky0/wBABCE5ud//4fBYAHWfAEACEJzu9229mFf+Pv7c68MdtIgjJRBPFuvHvcFx4D/+/cP7CSDLykQzzaAeDLEcvH8XJrj/dP/0TSXH7mhKGXxc2l0iN5It2q/n/uR1tSh+lE6lomHhohGhmVHiTzLDovdsbm2eNSB2sVjqWbtto+2SkzNCBfP534k//LyJ7t4LEfs2Aub64rneL9fHK5tOuzhPl4uR9rr535sLpdLgeEORrB4fi7M9Ww8sol46mFzbfF8FLbWEc/9507i/bkfj/ePet66ESoeXTv02DbiqYbN9cUjE7aSeD6fKd59tO1L82Li74pA8XzuRz0W08GNxFMLmzHEM3tt0zEb7j8R7yHa7HnrRV3iqYTNOOLp5SNdUeyYD/cY7zHaZYY7GOmWbZ/7UW2xvnjqYDOWeEb53FcTTx/v+xjtMsMdjDgPDBihcHKLIJ4q2IwnHuURpB0u4Za+Dig03MGI86i6/6g8HdWjGUM8NbAZUzwaVWY4hVtewVtvMbP9Xi0Ucb4k/fsTlzjbzXkU8VTAJl7PKQP/nAF2ksGXlD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Yf1Mws5S8TCzqMctKTdsOuvzt4raskBfIpv+W0xuqgX5PjDwEs8u2GGLk7CzTDxkPfCVj5rmZTWO4oPoqtsi66XD41OtOMXDUF9I4tkHO7yfObHDi0csRAWGSJAC2wwubvNIU23Wn/qaBqaNy7hEDshJKtikNdgO9YMBTVYFFc9+2GH8ZM+yETvpXs8xPR91r7BnxH49B+wEIJl4ZteafrcKe0Nk8YCdEODF0DKAF0MzBMRTBiCeDCGJJ/Kv7gCgNkzi2fxH4TCTvbCHQX4G8ZRhEE+GBvFsbLNfZgueNnd1P+ZOikE8JWa99PTZWIqcpHmwg5yk2thiZb308NnaIXKS5sEOcpIqFi/rZYDPWaUYaWRYxLMXdqghJ2marJfzPiMnaRHsfOUTISdpgqyXoT5nkVaxqT0nqbvP00nJPQ9yksbNehnocx7i0SF42hs7kiEnaYKsl14+Iydp1uywfiInaaSsl74+Z/XAwEs8u2BHMuQkjZr10t/nHB5VO9qr9JykYT4jJ2marJcePiMnaSHsICfpFD5kvQy22K/ngJ0ASyYeZL1cZJHFA3ZCDC+GlmF4MTRDg3jKMIgnQ3vhl6QAEIxBPP4/4QYA4PuFeAAgGBAPAATiP4Do0I6EP3cjAAAAAElFTkSuQmCC" alt="" />

oracle处理考勤时间,拆分考勤时间段的sql语句的更多相关文章

  1. 转 oracle数据库更新时间字段数据时的sql语句

    https://www.cnblogs.com/sun-rain/p/4921512.html ---Oracle数据库-时间函数 ---格式化时间插入update t_user u set u.mo ...

  2. mysql时间格式化,按时间段查询MYSQL语句

    描述:有一个会员表,有个birthday字段,值为'YYYY-MM-DD'格式,现在要查询一个时间段内过生日的会员,比如'06-03'到'07-08'这个时间段内所有过生日的会员. SQL语句: Se ...

  3. Oracle行转列、列转行的Sql语句总结

    多行转字符串 这个比较简单,用||或concat函数可以实现  SQL Code  12    select concat(id,username) str from app_userselect i ...

  4. Oracle行转列、列转行的Sql语句总结(转)

    多行转字符串 这个比较简单,用||或concat函数可以实现 select concat(id,username) str from app_userselect id||username str f ...

  5. Oracle的创建表和创建约束的Sql语句

    Oracle的创建表和创建约束的Sql语法 1.创建表的语句 ---1.创建模拟的数据表 --- --1.1.创建学生表Student create table Student( StuId NUMB ...

  6. oracle之 v$sql_monitor 监视正在运行的SQL语句的统计信息

    11g中引入了新的动态性能视图V$SQL_MONITOR,该视图用以显示Oracle监视的SQL语句信息.SQL监视会对那些并行执行或者消耗5秒以上cpu时间或I/O时间的SQL语句自动启动,同时在V ...

  7. Ora中select某时间段记录sql语句

    要查找某时间段的记录,例如查找2013-11-1到2013-11-30的记录. ' group by user_name, user_id 注意:SQL语句中含有sum累加函数,末尾要加group b ...

  8. oracle中用rownum分页并排序的查询SQL语句

    oracle的sql语句中没有limit,limit是mysql中特有的,在oracle中可用rownum来表示,用于查询结果中的前N行数据. 如要查询emp表中的前5行数据,可用如下语句: sele ...

  9. Oracle中查询和定位数据库问题的SQL语句

    --1)查询和定位数据库问题的SQL语句--Oracle常用性能监控SQL语句.sql --1查询锁表信息 select vp.SPID, vs.P1, vs.P1RAW, vs.P2, vs.EVE ...

随机推荐

  1. acdream.18.KIDx's Triangle(数学推导)

    KIDx's Triangle Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Sub ...

  2. Java中的final修饰符

    1.什么时候可以选择final修饰符 如果想让一个类不被其他类继承,不允许在有子类,这时候就要考虑用到final来修饰. 2.用final修饰的类 首先大家要明白,用final修饰的类是不能被继承的, ...

  3. /run/systemd/private: No such file or directory

    今天执行consul脚本的时候报错 /run/systemd/private: No such file or directory reboot -f 重启电脑private文件就出现了.

  4. 第7章 使用RAID与LVM磁盘阵列技术

    章节简述: 您好,此章节为新增加的知识内容,正在努力的排版完善,预习2016年9月中旬完成,感谢您的支持,QQ群:340829. 7.1  磁盘冗余阵列 1988年由加利福尼亚大学伯克利分校发表的文章 ...

  5. 【js】将table的每个td的内容自动赋值给其title属性

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. 怎样取出cobbler kopts中设置的参数?

    Is there a way to find out with what parameters did the kernel boot? For example if I specify noexec ...

  7. 【Python】Django 时间字段 最佳实践

    . python datetime from datetime import datetime datetime.now() datetime.utcnow() from datetime impor ...

  8. Combination Sum | & || & ||| & IV

    Combination Sum | Given a set of candidate numbers (C) and a target number (T), find all unique comb ...

  9. js init : function ()

    这个init外面应该还有一层,比如 var a = { init: function () {...}, exit: function () {...} } 这样的话,可以用a.init()来调用这个 ...

  10. cocos2d-x如何解决图片显示模糊问题

    转载http://zhidao.baidu.com/link?url=JTUKP5quGfMQixLZSvtC2XlKMkQDyQbYW72_DRyD6KDRpkLs8_6poQtKkwsyqzU8q ...