Selasa, 18 Agustus 2015

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

 

Phucon-


What is the SQL before you add the Order By?

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)




On Aug 18, 2015, at 11:06 PM, saigonf7q5@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:


The query which I used for filtering the "most recent date" and the "2nd most recent date" contains only 2200 records. However, that query consist of 2 tables, one of the table is almost 300,000 records.

The ODBC Call failed#195 error has gone away, the CDate function is working now, after I added the "Mytable.MyDateField Is Not Null" to the Where clause which originally from Crystal's post 111665. Then I use the Make Table query to dump the rows into a local table as you suggested. And I add the "Distinct" to Select statement of my "FilteringMostRecentDate" query, to eliminate the duplicated dates. It seems to be working ok now, showing the most recent and the 2nd most recent rows. 

One other thing that needs to be done is the sorting order. When I add an Order By clause, "Order By Institution, EntryDate desc;" it gives me this error: "ORDER BY clause (entrydate) conflicts with Distinct"

Why can't it be sorted? How do I fix it?

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 (9)

.

__,_._,___

Tidak ada komentar:

Posting Komentar