doulvyi2172 2013-02-18 11:11
浏览 99
已采纳

计算加班工时并将加班更新到表

I have table columns workhours and overtime, and I would like to do a SQL or PHP query that checks if the workinghours are over 8 hours and if so it UPDATEs the worked overtime to overtime column.

Here's my table:

id   workinghours    overtime
1,   4.79,           ---
2,   8.73,           ---
3,   7.97,           ---  

For example on the second row there is 8.73 hours of work and so it would update the 0.73 hours to the overtime column.

  • 写回答

3条回答 默认 最新

  • doufuxing8562 2013-02-18 11:27
    关注

    query :

    update work set overtime= (case when working > 8 then (working - 8) else null end);
    

    check SQL Fiddle Demo

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现