我有这个查询:
SELECT TM_User.FullName ,
Task.end_date
FROM TM_User
INNER JOIN (
SELECT Task.task_id ,
Task_Hours.user_id ,
ROW_NUMBER() OVER ( PARTITION BY user_id ORDER BY Task.end_date DESC ) rtt ,
Task.end_date
FROM Task_Hours
INNER JOIN (
SELECT Task.task_id ,
Task.end_date ,
ROW_NUMBER() OVER ( PARTITION BY Task.task_id ORDER BY Task.end_date DESC ) rr
FROM Task
WHERE Task.start_dte >= '2013-08-15'
AND Task.end_date <= '2013-08-31'
) Task ON Task.task_id = Task_Hours.task_id
) a ON TM_User.TM_UserID = a.user_id
WHERE a.rtt = 1
AND is_active = 1