SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    return entire row where a value = max(value)

    Hey folks -

    SQL query please.
    I've looked this up on the internet and other forums by example but I can't seem to make it work for my specific requirements. I hope someone can point me in the right direction.

    I have a fictional list of bookmakers for a project I'm working on, and odds of an event happening. it has the following columns.

    book, home, away, home_odds and away_odds.

    There are several books all offering odds on the same event - I want to return the name of the book and the odds for the best odds for home_odds


    if you can imagine something like this:

    Code SQL:
    SELECT book, home_odds WHERE home_odds = MAX(home_odds)

    I know this isn't correct but could someone point me in the right direction?

    Many thanks.
    DS

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Would this query suffice?
    Code sql:
    SELECT book, home_odds FROM TABLE ORDER BY home_odds DESC LIMIT 1
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Indeed it did - thanks!
    Couldn't see the wood for the trees

    Well done, sir.

    DS


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
  •