Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
464 Points
92 Posts
Aug 06, 2007 07:38 AM|LINK
Create 3 table variables for each @TotalHoursWorked etc. having columns EmpID and the TotalHoursWorked and insert like this
Insert into @TotalHoursWorked
INNER JOIN Employee E ON P.EmpID_fk = E.EmpID // newly added join
WHERE P.EmpID_fk = E.EmpID
AND P.DateWorked Between @JoinDate AND @CurrentDate
group By E.EmpID)
This will give the Employees and thier Sum
and then in the main query you join with these tables on empid to get the result.
abhishek2981
Member
464 Points
92 Posts
Re: Web-App waiting for indefinite time
Aug 06, 2007 07:38 AM|LINK
Create 3 table variables for each @TotalHoursWorked etc. having columns EmpID and the TotalHoursWorked and insert like this
Insert into @TotalHoursWorked
Values(SELECT EmpID, SUM (P.HoursWorked) FROM Presence PINNER JOIN Employee E ON P.EmpID_fk = E.EmpID // newly added join
WHERE P.EmpID_fk = E.EmpID
AND P.DateWorked Between @JoinDate AND @CurrentDate
group By E.EmpID)
This will give the Employees and thier Sum
and then in the main query you join with these tables on empid to get the result.