员工考勤表两条数据合并
问个关于考勤的问题 就是有个考勤表 每天都有上下班签到 插入到数据库中是两条记录 上班和下班 我想在查询时在控件中只显示一条 并且有上班和下班的签到的状态(主要是在一个表中的两条数据如何合并成一条) 求解方法 最好详细点
PunchCardID int primary key identity(1,1),
EmpLoyeeNum varchar(50) ,---员工编号
UserName varchar(50),--姓名
PunchCardDate varchar(50),--打卡时间
ClassesNumName varchar, --班次
PunchBeLate varchar(10),---是否迟到
PunchCardImg Image, ---打卡照片
NowYear int, ---年
NowMonth int, ---月
NowDayID int,---//打卡日期
LateTime varchar,---------迟到时间(单位小时)
PunchType int -- (0:上班,1:下班)
------解决方案-------------------- select a.*,a.PunchCardDate as 上班打卡时间,b.PunchCardDate as 下班打卡时间
from
(select * from PunchCard where PunchType =0) a
left join
(select * from PunchCard where PunchType =1) b
on a.EmpLoyeeNum =b.EmpLoyeeNum and a.NowYear =b.NowYear and a.NowMonth=b.NowMonth and a.NowDayID=b.NowDayID
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/
------解决方案-------------------- 引用: select a.*,a.PunchCardDate as 上班打卡时间,b.PunchCardDate as 下班打卡时间
from
(select * from PunchCard where PunchType =0) a
left join
(select * from PunchCard where PunchType =1) b
on a.EmpLoyeeNum =b.EmpLoyeeNum and a.NowYear =b.NowYear and a.NowMonth=b.NowMonth and a.NowDayID=b.NowDayID
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/
join 就好了吧,上班漏打卡的咋整