Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Last Records select
Message
From
14/08/2013 13:01:06
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2000
Application:
Desktop
Miscellaneous
Thread ID:
01580460
Message ID:
01580481
Views:
32
>>I'm trying to create a View in SQL 2000 from/for a TimeClock database that will select the last record for employees (that aren't currently clocked in)
>>
>>Here is a Select statement and the data below is returned:
snip...

Borislav,
Thanks so much, that helped tremendously! Here is what I ended up doing
SELECT cast(dbo.EmployeeHours.EmployeeId as Int) as EmployeeID,
	dbo.EmployeeList.FirstName + ' ' + dbo.EmployeeList.LastName AS Name,
       dbo.EmployeeHours.TimeIn,
       dbo.EmployeeHours.TimeOut,
       cast(dbo.EmployeeHours.JobCode as Int) as JobCode, 
       dbo.MasterJobCodeList.Description,
       dbo.EmployeeHours.CostCode
FROM dbo.EmployeeHours
INNER JOIN dbo.MasterCostCodeList ON dbo.EmployeeHours.CostCode = dbo.MasterCostCodeList.Level1
INNER JOIN dbo.MasterJobCodeList ON dbo.EmployeeHours.JobCode = dbo.MasterJobCodeList.JobCode
INNER JOIN (SELECT EmployeeId,
                  MAX(TimeOut) AS TimeOut
            FROM dbo.EmployeeHours
            GROUP BY EmployeeId) EmplMax
      ON EmplMax.EmployeeId = dbo.EmployeeHours.EmployeeId
     AND EmplMax.TimeOut = dbo.EmployeeHours.TimeOut
INNER JOIN dbo.EmployeeList ON dbo.EmployeeHours.EmployeeId = dbo.EmployeeList.EmployeeId
WHERE dbo.MasterCostCodeList.Active = 1
  AND NOT dbo.EmployeeHours.TimeOut IS NULL
ORDER BY dbo.EmployeeHours.employeeID Asc
Thanks
Jon
Non-MVP Non-MCP Non-MCSE

Visual FoxPro, What else is there?
Previous
Reply
Map
View

Click here to load this message in the networking platform