Back to post list
Back a step
Replies:
Add reply:
Back a step
Nate
Posts: 5,727 Status: King Karma: +2,355 [+1] [-1] |
Subject: Queries | |||||
SELECT X.*, Y.WeeklyHours AS CURRENTHOURS FROM (SELECT FirstName + ' ' + LastName AS EmployeeName, CountryName, SUM(hoursWorked) AS WeeklyHours, datepart(week, convert(smalldatetime, (convert(varchar(2), w.WH_Month) + '/' + convert(varchar(2), w.WH_Day) + '/' + convert(varchar(4), w.WH_Year)))) AS WeekNum FROM Employees e, Countries c, WorkHours w WHERE e.EmpID = w.EmpID AND e.CountryID = c.CountryID GROUP BY LastName, FirstName, CountryName, datepart(week, convert(smalldatetime, (convert(varchar(2), w.WH_Month) + '/' + convert(varchar(2), w.WH_Day) + '/' + convert(varchar(4), w.WH_Year)))) ) X LEFT OUTER JOIN (SELECT FirstName + ' ' + LastName AS EmployeeName, CountryName, SUM(hoursWorked) AS WeeklyHours, datepart(week, convert(smalldatetime, (convert(varchar(2), w.WH_Month) + '/' + convert(varchar(2), w.WH_Day) + '/' + convert(varchar(4), w.WH_Year)))) as WeekNum FROM Employees e, Countries c, WorkHours w WHERE e.EmpID = w.EmpID AND e.CountryID = c.CountryID AND datepart(week, convert(smalldatetime, (convert(varchar(2), w.WH_Month) + '/' + convert(varchar(2), w.WH_Day) + '/' + convert(varchar(4), w.WH_Year)))) = DATEPART(WEEK, GETDATE()) GROUP BY LastName, FirstName, CountryName, datepart(week, convert(smalldatetime, (convert(varchar(2), w.WH_Month) + '/' + convert(varchar(2), w.WH_Day) + '/' + convert(varchar(4), w.WH_Year)))) ) Y ON X.EmployeeName = Y.EmployeeName AND X.CountryName = Y.CountryName AND X.WeekNum = Y.WeekNum |
||||||
|
Replies:
- Uhh - NinjaBlaze
- wtf? - Baldr
- i only - Rydel
- I'm about as well versed - SAJASE
- i think the problem - Anonymous
- well here is the function im deguggin right now... - FlUfFy6969
- opps - FlUfFy6969
Add reply: