Kamis, 20 Agustus 2015

Re: [MS_AccessPros] SQL find Max or most recent dates

 

Hello Mr. Viescas

 

Here is the SQL code before I add the Order By clause

 

SELECT DISTINCT a.InstNum, CDate(Int(a.DateEntry)), a.Comment, a.InitUser, a.LastUser
FROM tblRiskReview AS a
WHERE (((a.DateEntry) Is Not Null And (a.DateEntry)=(select max(DateEntry) from tblRiskReview as b where b.InstNum =a.InstNum))) OR (((a.DateEntry)=(select max(DateEntry) from tblRiskReview as c where c.InstNum = a.InstNum and c.DateEntry < (select max(DateEntry) from tblRiskReview as d where d.InstNum = a.InstNum))));

 

Here is the Order By clause.


ORDER BY a.InstNum, a.DateEntry;

 

When the "DateEntry" is added to the SQL, it generates this error message: Order By clause (a.DateEntry) conflicts with DISTINCT.

 

Phucon

__._,_.___

Posted by: saigonf7q5@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (10)

.

__,_._,___

Tidak ada komentar:

Posting Komentar