我用过查询: -
select
employees.N, employees.ID, Date(Month) as m, count(*) as P,
(FullOrHalfLeave) as FOH
from
employees, leaveapplication, leaveapplicationdetails
where
employees.ID = leaveapplication.ID
and leaveapplication.LeaveApplicationID = leaveapplicationdetails.Leave_Application_ID
and TypeOfLeave = 1
and LeaveStatus = 4
and employees.ID = 18
group by
employees.ID,FOH
order by
employee.N, FOH
我得到如下结果: -
N ID m P FOH
--------------------------------------
A 18 1 8 1
A 18 1 3 2
A 18 4 6 1
A 18 5 3 1
A 18 5 1 2
A 18 6 3 2
A 18 9 1 1
A 18 9 4 2
我想要这样的结果:
N ID m Pad FOH
----------------------------------------
A 18 1 9.5 -
A 18 4 6 -
A 18 5 3.5 -
A 18 6 1.5 -
A 18 9 3 -
答案 0 :(得分:0)
你不需要返回FOH,只需这样做:
select employees.N, employees.ID, Date(Month) as m, SUM(1 / FullOrHalfLeave) as P
这样,如果FOH = 1
,那么您将计算一天,如果FOH = 2
您将计算半天。