Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Last Records select
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Application:
Desktop
Divers
Thread ID:
01580460
Message ID:
01580481
Vues:
31
>>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?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform