Help with displaying ONLY the most current record

Results 1 to 5 of 5

Thread: Help with displaying ONLY the most current record

  1. #1
    Zola Guest

    Default Help with displaying ONLY the most current record

    I am working on a database that will be updated once a week. I am trying to create a SQL statement that will fetch only the most current records, added at that week&#039s update. How do I do this? Can I use SELECT MAX(DATE)?

  2. #2
    Join Date
    Dec 1969
    Posts
    64

    Default RE: Help with displaying ONLY the most current record

    I&#039ve done this using an autoincremented field (I&#039ll call it table_id):<BR><BR>&nbsp;&nbsp;&nbsp;SELECT table_id=MAX(table_id) <BR>&nbsp;&nbsp;&nbsp;FROM table_name<BR><BR>As an alternative, I think this would work:<BR><BR>&nbsp;&nbsp;&nbsp;SELECT * <BR>&nbsp;&nbsp;&nbsp;FROM table_name <BR>&nbsp;&nbsp;&nbsp;WHERE table_id=MAX(table_id)<BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    118

    Default RE: Help with displaying ONLY the most current rec

    Hi, your answer may resolve my question, but another question, what is the correct syntax for select top 5(say) from a table to display just the top five records? I ask because the maxrecords.prop is ignored in access and I keep getting errors for the select statement. <BR>thanks in advance for any help with this.<BR>bruce

  4. #4
    Zola Guest

    Default RE: Help with displaying ONLY the most current rec

    Unforunately, it won&#039t let me use the Table_name(MAX) in the WHERE statement. I have worked around it by making a special column for the "week ending" date. I then tell SQL to compare:<BR>WHERE EventDate &#062;=Week. You have to use the online form to manually change the date every week, but that is hardly big deal.


  5. #5
    Zola Guest

    Default RE: Help with displaying ONLY the most current rec

    Do you have a numerical value connected with these entries? If you do, that makes it a lot easier. For example, if you are figuring out placement, like in a "vote for top song" column, you probably have the db list by place. In that case, you would use BETWEEN:<BR><BR>SQL="SELECT WhateverField FROM WhateverTable WHERE Place BETWEEN 1 AND 5"<BR><BR>I have a page I would be happy to mail you if you would like to see a similar operation, just drop me a line at zola@zolaweb.com

Posting Permissions

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