Select TOP 10 SQL statement

Results 1 to 3 of 3

Thread: Select TOP 10 SQL statement

  1. #1
    Victor Tai Guest

    Default Select TOP 10 SQL statement

    I wrote an SQL statement to take the top 10 latest data from a table. This SQL statemet din&#039t work and return me all the data.<BR>My SQL statement:<BR><BR>"SELECT TOP 10 * FROM aTable ORDER BY aDate"<BR><BR>aDate is a field of aTable which is type Date. This statement works well only when I take out the "ORDER BY aDate"<BR><BR>How do I modify this SQL statement so it can works?<BR><BR>Thanks.<BR><BR>vic

  2. #2
    Join Date
    Dec 1969

    Default RE: Select TOP 10 SQL statement

    I don&#039t know how to do that in SQL, I am sure there is a way, but what I would do is do it via the recordset. I don&#039t remember all the syntax, but it something like:<BR><BR>open the recordset<BR>count the recordset<BR>then move to the last record - 10<BR>then display the records you have from the one you are on to the eof.<BR><BR>Hope that helps.

  3. #3
    Join Date
    Dec 1969

    Default RE: Select TOP 10 SQL statement

    From online help in MS Access 97:<BR><BR>&#062;SELECT TOP 25<BR>&#062;FirstName, LastName<BR>&#062;FROM Students<BR>&#062;WHERE GraduationYear = 1994<BR>&#062;ORDER BY GradePointAverage DESC;<BR>&#062;<BR>&#062;The TOP predicate doesn&#039t choose between <BR>&#062;equal values. In the preceding example, if the <BR>&#062;twenty-fifth and twenty-sixth highest grade <BR>&#062;point averages are the same, the query will <BR>&#062;return 26 records.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts