Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


TSQL Challenge 72 - Calculate the Payroll Hours of Employees


TSQL Challenge 72 - Calculate the Payroll Hours of Employees

Author
Message
jacob sebastian
jacob sebastian
SSC-Addicted
SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)

Group: General Forum Members
Points: 472 Visits: 2523
Comments posted to this topic are about the item TSQL Challenge 72 - Calculate the Payroll Hours of Employees

.
mahesh_patel2004a
mahesh_patel2004a
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 11
SELECT dbo.TC72_Employees.EmpID, dbo.TC72_Employees.EmpName, SUBSTRING(CAST(CONVERT(Date, dbo.TC72_PayrollWeek.WeekStart, 102) AS Varchar(12)), 6, 2)
+ '-' + SUBSTRING(CAST(CONVERT(Date, dbo.TC72_PayrollWeek.WeekStart, 102) AS Varchar(12)), 9, 2) + '-' + SUBSTRING(CAST(CONVERT(Date,
dbo.TC72_PayrollWeek.WeekStart, 102) AS Varchar(12)), 1, 4) AS WeekStart, SUBSTRING(CAST(CONVERT(Date, dbo.TC72_PayrollWeek.WeekEnd, 102)
AS Varchar(12)), 6, 2) + '-' + SUBSTRING(CAST(CONVERT(Date, dbo.TC72_PayrollWeek.WeekEnd, 102) AS Varchar(12)), 9, 2) + '-' + SUBSTRING(CAST(CONVERT(Date,
dbo.TC72_PayrollWeek.WeekEnd, 102) AS Varchar(12)), 1, 4) AS WeekEnd, CAST(D.EarningCode AS Varchar) AS Expr1, D.Hours
FROM dbo.TC72_Employees INNER JOIN
dbo.TC72_PayrollWeek ON dbo.TC72_Employees.EmpID = dbo.TC72_PayrollWeek.EmpID INNER JOIN
(SELECT EmpID, MIN(VisitDate) AS WeekStartDate, MAX(VisitDate) AS WeekEndDate
FROM dbo.TC72_EmployeeVisits
GROUP BY EmpID) AS C INNER JOIN
(SELECT EarningCode, SUM(DATEDIFF(Minute, StartTime, EndTime) / 60.0) AS Hours, EmpID
FROM dbo.TC72_EmployeeVisits AS TC72_EmployeeVisits_1
GROUP BY EarningCode, EmpID) AS D ON C.EmpID = D.EmpID ON dbo.TC72_PayrollWeek.EmpID = C.EmpID AND
dbo.TC72_PayrollWeek.WeekStart = C.WeekStartDate AND dbo.TC72_PayrollWeek.WeekEnd = C.WeekEndDate
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search