how to select sql max function value PLUS another cell from same record?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • omar999
    New Member
    • Mar 2010
    • 120

    how to select sql max function value PLUS another cell from same record?

    I can use the select sql max function with no problems;

    this is my code
    Code:
    SELECT MAX(Bid_Amount) AS LargestBidAmount FROM Auction_1
    then to output using asp
    Code:
    Response.Write "<td class=""numbertd"">" & objRS("LargestBidAmount") & "</td>"

    but how do I also select another cell data [in my case 'name'] from the same record?


    would it be something like this....?;
    Code:
    SELECT Name, MAX(Bid_Amount) AS LargestBidAmount FROM Auction_1 UNION SELECT NAME From Auction_1
    thanks in advance
    Omar.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    You're going to have to rejoin it to your table. Try something like:

    Code:
    select * from Auction_1
    where bid_amount = (SELECT MAX(Bid_Amount) FROM Auction_1)
    This will get all records with the highest amount. Just in case there are "ties" :)

    Happy Coding!!!

    ~~ CK

    Comment

    • omar999
      New Member
      • Mar 2010
      • 120

      #3
      this worked a treat !

      your a life saver - thank you : )

      Comment

      Working...