M
MrElam
I am using VS 2005 (no LINQ) and have been trying to figure out how to
put these two queries together. Basically, I have one SELECT
statement that gets the Max workdate by EmpID, and I want to join that
to another SELECT statement that pulls out info just for that Max
date. Each statement works fine on it's own, but I can't figure out
how to put them together. Here is some pseudo-code:
SELECT t1.EmpID, Max(t1.Workdate) as MaxDate
FROM Timetable as t1
GROUP BY t1.EmpID
JOIN TO
SELECT t2.EmpID, t2.Workdate, t2.StartTime, t2.EndTime, t2.WorkDescr
FROM Timetable as t2
ON t1.EmpID=t2.EmpID AND t1.Workdate=t2.Workdate
Has anyone tried to do this before? Is it possible?
put these two queries together. Basically, I have one SELECT
statement that gets the Max workdate by EmpID, and I want to join that
to another SELECT statement that pulls out info just for that Max
date. Each statement works fine on it's own, but I can't figure out
how to put them together. Here is some pseudo-code:
SELECT t1.EmpID, Max(t1.Workdate) as MaxDate
FROM Timetable as t1
GROUP BY t1.EmpID
JOIN TO
SELECT t2.EmpID, t2.Workdate, t2.StartTime, t2.EndTime, t2.WorkDescr
FROM Timetable as t2
ON t1.EmpID=t2.EmpID AND t1.Workdate=t2.Workdate
Has anyone tried to do this before? Is it possible?