Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to get First() function equivalent in T-SQL?

Author  Topic 

khinebo
Starting Member

2 Posts

Posted - 2001-07-24 : 05:54:05
There's a function in MS Access/Jet SQL called 'First()' which I found very useful. It works something like this. A normal SQL query such as below will return me repeated employee names for those persons who clocked in two or more times during that day:

SELECT
T1.Name,
T2.InTime
FROM
Employee T1
INNER JOIN
Attendance T2
ON
T2.EmployeeID = T1.EmployeeID

If I am interested in only the *first* clock-in time for any one employee, then I could re-write the query like this in Jet SQL:

SELECT
T1.Name,
First(T2.InTime)
FROM
Employee T1
INNER JOIN
Attendance T2
ON
T2.EmployeeID = T1.EmployeeID
GROUP BY
T1.Name

Is there an equivalent method in SQL Server which will return me the same result as above?

KB

   

- Advertisement -