我運行上面的sql語句,我得到了這個。[IMG] http://i1093.photobucket.com/albums/i422/walkgirl_1993/asd-1_zps5506632e.jpg [/ IMG]我試着顯示你可以看到3和4的最新日期。對於caseid 3,它應該顯示2012-12-20 16:12:36.000的最新行。我嘗試使用group by,order by。谷歌一些網站說,使用排名,但我不知道排名,因爲我真的沒有排名。一些建議?從一個ID獲取最新日期
select [Case].CaseID, Agent.AgentName, Assignment.Description, A.AgentName as EditedBy, A.DateEdited from Agent inner join [Case-Agent] on [Case-Agent].AgentID = Agent.AgentID inner join [Assignment] on Assignment.AssignmentID = [Case-Agent].AssignmentID inner join [Case] on [Case].CaseID = [Case-Agent].CaseID inner join (select EditedCase.CaseID, [EditedCase].DateEdited, [Agent].AgentName from EditedCase inner join [Agent] on [Agent].AgentID = [EditedCase].AgentID) A on A.CaseID = [Case].CaseID where [Assignment].AssignmentID = 0
非常感謝!它實際上有效!但我仍然沒有得到排名的想法 – BunnyRiven