解决方案 »
- jquery+json+struts2+spring ajax回调函数不执行
- jsp 导出word,如何搞?
- java如何读取复杂Excel内容
- 从数据表中读取出数据显示到Treeview中 请各位大侠帮帮菜鸟
- xfire 大文件传送例子300M左右的文件
- AJAX框架的使用
- jndi,ejb这些代码我都看的懂,但自己不会搞,请问我应该怎么入门?
- 我现在学习ing j2ee,请高手指点指点,现在j2ee方面太多内容了, 我都不知道从何下手??汗~~~
- 关于CMR时调用ejbCreate或ejbPostCreate中的问题,急!急!急
- EJB的问题
- 线程是Runnable,偶尔 java.lang.ClassLoader.defineClass1(Native Method)会卡住
- java 二维码
oa_check_out d join
(select a.person_id,out_times,leave_times,late_times from
(select a.person_id,count(*) as out_times from oa_check_out a where status=1 and reason !='WCBS' group by a.person_id) a join
(select a.person_id,count(*) as leave_times from oa_check_leave a where status=1 group by a.person_id) b on a.person_id=b.person_id left join
(select a.person_id,count(*) as late_times from oa_check_out a where status=1 and reason ='WCBS' group by a.person_id) e on
e.person_id=a.person_id) c on
d.person_id=c.person_id
不好意思哈,哥们。
oa_check_out d join
(select a.person_id,out_times,leave_times,late_times from
(select a.person_id,count(*) as out_times from oa_check_out a where status=1 and reason !='WCBS' group by a.person_id) a join
(select a.person_id,count(*) as leave_times from oa_check_leave a where status=1 group by a.person_id) b on a.person_id=b.person_id left join
(select a.person_id,count(*) as late_times from oa_check_out a where status=1 and reason ='WCBS' group by a.person_id) e on
e.person_id=a.person_id) c on
d.person_id=c.person_id
不好意思哈,哥们。
再将两个结果关联 就出来了
用了group就只能像我写的那样去表现其他字段了吗?我这样查询会有数据遗漏吗?
select person_id,
sum(case when status1=1 and reason !='WCBS' then 1 else 0 end) as out_times,
sum(case when status2=1 then 1 else 0 end) as leave_times,
sum(case when status1=1 and reason ='WCBS' then 1 else 0 end) as late_times
from
(
select person_id,status as status1 ,null as status2, reason from oa_check_out
union all
select person_id,null as status1, status as status2, reason from oa_check_leave
) un
group by person_id
楼主看看这是不是你要的