SELECT * from TEST
SELECT ApplyerDeptName,ApplyName,HR10day,sum(HRdays)as UsedDay,(HR10day-sum(HRdays))as UnusedDay
FROM afu_form_HR10 inner join TEST on
afu_form_HR10.ApplyName=TEST.HR10name where ApplyDateTime Between '20120101' and '20121231' and Excuse='特休假'
group by ApplyerDeptName,ApplyName,HR10day
------------------------------------------------------------------------
資料表有dbo.test,dbo.test2(檢視表),afu_form_HR10 謝謝!
------------------------------------------------------------------------
SELECT ApplyerDeptName,ApplyName,HR10day,sum(HRdays)as UsedDay,(HR10day-sum(HRdays))as UnusedDay
FROM afu_form_HR10 inner join TEST on
afu_form_HR10.ApplyName=TEST.HR10name where ApplyDateTime Between '20120101' and '20121231' and Excuse='特休假'
group by ApplyerDeptName,ApplyName,HR10day
------------------------------------------------------------------------
資料表有dbo.test,dbo.test2(檢視表),afu_form_HR10 謝謝!
------------------------------------------------------------------------