CREATE PROCEDURE dbo.ApiRcpWorkTimeSummary
@DepartamentId int,
@WorkerId int,
@DayFrom int,
@DayTo int
AS
BEGIN
CREATE TABLE #worktime(
Name nvarchar(100),
Surname nvarchar(100),
Id int,
WorkerId int,
Day int,
TimeQualified int,
TimeQualifiedHours int,
Date datetime
);

INSERT INTO #worktime
exec dbo.ApiRcpWorkTime -1,0,0,10000;

select  WorkerId Id, Surname Nazwisko, Name Imie, Sum(TimeQualified)/60 CzasPracyGodziny 
from #worktime group by WorkerId, Surname, Name
ORDER BY Surname;

drop table #worktime;
END

