| Author |
simple MAX SQL returns wrong result (!)
|
Peter Primrose
Ranch Hand
Joined: Sep 10, 2004
Posts: 755
|
|
Can't figure it out why the MAX return-result is incorrect. here's my table result (composed of 2 tables)  I would like to get the highest bidder, for this I'm using the MAX: but the result is: Why? the highest bidder is Tony Soprano not DELL
|
 |
Amit M Tank
Ranch Hand
Joined: Mar 28, 2004
Posts: 257
|
|
|
because 745 is greater than other numbers of the coulmn. seems there is something fundamentally wrong in your question.
|
Amit Tank
Linked In
|
 |
Peter Primrose
Ranch Hand
Joined: Sep 10, 2004
Posts: 755
|
|
seems there is something fundamentally wrong in your answer :-) if 745 is the highest bid why the result for *legal_name* is dell and not * tony soprano* and how do I correct this?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
ORDER BY ? I think you are choosing the highest bid for each of the bidders, not the highest bid of all.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26193
|
|
Peter, I think you want something more like this: The max check is in the where clause so it hones in on the record you are looking for. (I didn't run this, so the syntax might be a bit off.)
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Peter Primrose
Ranch Hand
Joined: Sep 10, 2004
Posts: 755
|
|
yes, you are correct. the 'MAX' should be on the 'WHERE'. THANK YOU!
|
 |
 |
|
|
subject: simple MAX SQL returns wrong result (!)
|
|
|