首页 > 其他 > 详细

查询员工最后一个月的工资情况

时间:2015-07-03 00:20:13      阅读:200      评论:0      收藏:0      [点我收藏+]

select * from employee

empid  name

001 张三

002 李四

003 王五


select * from salary

empid  month salary

001   1    100

001   2    200

001   3    300

002   1    200

002   2    400

003   3    500


select t3.name , t1.empid,t1.month,t2.salary from (

select empid,max(month) month from salary  group by empid) t1

 left join salary t2 on t2.empid = t1.empid and t2.month = t1.month

 left join employee t3 on t3.empid = t2.empid


查询员工最后一个月的工资情况

原文:http://ljt7560868.blog.51cto.com/4076512/1670374

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!