Kamis, 20 Agustus 2015

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

 

Phucon-

Use:

ORDER BY InstNum, CDate(Int(a.DateEntry))

John Viescas

Sent from my iPad

On Aug 20, 2015, at 21:05, saigonf7q5@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

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: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (11)

.

__,_._,___

Tidak ada komentar:

Posting Komentar