能能不能写出来啊晕,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
解决方案 »
- 求助一个关于全表扫描的问题
- oracle9i enterprise manager console为什么登陆不了
- ORACLE突然连不上!
- ◆◆◆【plsql的四个数据导入接口比较:imp,odbc,txt,forupdate…】◆◆◆
- 为什么这个程序只能插入GIF图片?
- 最菜的问题,怎么在SQLPLUS里面调出记事本,对SQL语句进行修改呢?进来就给分
- 如果有字符串"aa,bb,cc,dd" 如何实现按照","的分隔,分别取出字符串"aa","bb","cc","dd"呢
- 如何取得选修所有课程(cid)的学生sid
- 请问:触发器为行级时, BEFORE 和 AFTER 有什么区别 ?
- 关于Oracle.managedDataAccess.dll连接数据库问题
- 在virtual box上安装cluster提示错误
- 求sql语句
能能不能写出来啊晕,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
哥你好强劲,我刚刚才看到,一会套一下看下
能能不能写出来啊晕,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
哥,我放进去,提示,unknown column r.curdate in where clause
能能不能写出来啊我只是给你个样子 又不是叫你照我的写,这一段((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了