SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2003
    Location
    Halifax
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Returning last two occuring dates?

    I need to return the last 2 occuring dates from a table, is there a simple way to do this in MySQL. I know SQL Server has TOP syntax.

    The only way I can see to do this is:

    Code:
    SELECT DISTINCT date FROM rank 
    ORDER BY date DESC
    LIMIT 0,2
    This itself seems ok, however I need to fit this in to a larger query, without sub selects it looks as though I would need to write two queries and splice the arrays together before displaying.

    Any simpler syntax would be greatly appreciated.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    there is nothing simpler than that
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2003
    Location
    Halifax
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thought as much, cheers for confirming my thoughts.


Bookmarks

Posting Permissions

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