3,490
社区成员
发帖
与我相关
我的任务
分享
((select count(*) from qin_record where curdate = r.curdate and 上午上班 = null and 上午迟到 = null) + (select count(*) from qin_record where curdate = r.curdate and 下午上班 = null and 下午迟到 = null)) 当天缺勤次数
是t1.curdate了select t1.*,
((select count(*)
from qin_record
where curdate = r.curdate
and 上午上班 = null
and 上午迟到 = null) +
(select count(*)
from qin_record
where curdate = r.curdate
and 下午上班 = null
and 下午迟到 = null)) 当天缺勤次数
from (select t.*,
(select time
from qin_record
where timeslotid = 5
and curdate = t.curdate
and 上午上班 = null limit 1) 上午迟到,
(select time
from qin_record
where timeslotid = 6
and curdate = t.curdate
and 下午上班 = null limit 1) 下午迟到,
(select time
from qin_record
where timeslotid = 7
and curdate = t.curdate
and 上午下班 = null limit 1) 上午早退,
(select time
from qin_record
where timeslotid = 8
and curdate = t.curdate
and 下午下班 = null limit 1) 下午早退
from (select u.username,
r.curdate,
(select time
from qin_record
where timeslotid = 1
and curdate = r.curdate limit 1) 上午上班,
(select time
from qin_record
where timeslotid = 2
and curdate = r.curdate limit 1) 上午下班,
(select time
from qin_record
where timeslotid = 3
and curdate = r.curdate limit 1) 下午上班,
(select time
from qin_record
where timeslotid = 4
and curdate = r.curdate limit 1) 下午下班
from qin_record r, ums_user u
where r.userid = u.id
group by u.username, r.curdate) t) t1
order by t1.curdate desc
[/quote]
哥,我放进去,提示,unknown column r.curdate in where clauseselect t1.*,
((select count(*)
from qin_record
where curdate = r.curdate
and 上午上班 = null
and 上午迟到 = null) +
(select count(*)
from qin_record
where curdate = r.curdate
and 下午上班 = null
and 下午迟到 = null)) 当天缺勤次数
from (select t.*,
(select time
from qin_record
where timeslotid = 5
and curdate = t.curdate
and 上午上班 = null limit 1) 上午迟到,
(select time
from qin_record
where timeslotid = 6
and curdate = t.curdate
and 下午上班 = null limit 1) 下午迟到,
(select time
from qin_record
where timeslotid = 7
and curdate = t.curdate
and 上午下班 = null limit 1) 上午早退,
(select time
from qin_record
where timeslotid = 8
and curdate = t.curdate
and 下午下班 = null limit 1) 下午早退
from (select u.username,
r.curdate,
(select time
from qin_record
where timeslotid = 1
and curdate = r.curdate limit 1) 上午上班,
(select time
from qin_record
where timeslotid = 2
and curdate = r.curdate limit 1) 上午下班,
(select time
from qin_record
where timeslotid = 3
and curdate = r.curdate limit 1) 下午上班,
(select time
from qin_record
where timeslotid = 4
and curdate = r.curdate limit 1) 下午下班
from qin_record r, ums_user u
where r.userid = u.id
group by u.username, r.curdate) t) t1
order by t1.curdate desc
[/quote]
哥你好强劲,我刚刚才看到,一会套一下看下select t1.*,
((select count(*)
from qin_record
where curdate = r.curdate
and 上午上班 = null
and 上午迟到 = null) +
(select count(*)
from qin_record
where curdate = r.curdate
and 下午上班 = null
and 下午迟到 = null)) 当天缺勤次数
from (select t.*,
(select time
from qin_record
where timeslotid = 5
and curdate = t.curdate
and 上午上班 = null limit 1) 上午迟到,
(select time
from qin_record
where timeslotid = 6
and curdate = t.curdate
and 下午上班 = null limit 1) 下午迟到,
(select time
from qin_record
where timeslotid = 7
and curdate = t.curdate
and 上午下班 = null limit 1) 上午早退,
(select time
from qin_record
where timeslotid = 8
and curdate = t.curdate
and 下午下班 = null limit 1) 下午早退
from (select u.username,
r.curdate,
(select time
from qin_record
where timeslotid = 1
and curdate = r.curdate limit 1) 上午上班,
(select time
from qin_record
where timeslotid = 2
and curdate = r.curdate limit 1) 上午下班,
(select time
from qin_record
where timeslotid = 3
and curdate = r.curdate limit 1) 下午上班,
(select time
from qin_record
where timeslotid = 4
and curdate = r.curdate limit 1) 下午下班
from qin_record r, ums_user u
where r.userid = u.id
group by u.username, r.curdate) t) t1
order by t1.curdate desc