我运行上面的 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。谷歌一些网站说使用排名,但我不确定排名,因为我没有真正获得排名。一些建议?
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