SELECT with GROUP BY Joined to Subquery



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


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?

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

INNER JOIN auto changes 6
Top X from joined table 1
Group By, Max and Min 2
Possible in Linq to Sql? 3
Concatenate with ORDER BY clause 2
Subquery help? 3
help with query 1
need help with a sql statement 6