473,440 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,440 software developers and data experts.

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

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

this is my code
Expand|Select|Wrap|Line Numbers
  1. SELECT MAX(Bid_Amount) AS LargestBidAmount FROM Auction_1
  2.  
then to output using asp
Expand|Select|Wrap|Line Numbers
  1. Response.Write "<td class=""numbertd"">" & objRS("LargestBidAmount") & "</td>"
  2.  

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


would it be something like this....?;
Expand|Select|Wrap|Line Numbers
  1. SELECT Name, MAX(Bid_Amount) AS LargestBidAmount FROM Auction_1 UNION SELECT NAME From Auction_1
  2.  
thanks in advance
Omar.
Mar 22 '10 #1

✓ answered by ck9663

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

Expand|Select|Wrap|Line Numbers
  1.  
  2. select * from Auction_1
  3. where bid_amount = (SELECT MAX(Bid_Amount) FROM Auction_1)
  4.  
  5.  
This will get all records with the highest amount. Just in case there are "ties" :)

Happy Coding!!!

~~ CK

2 3082
ck9663
2,878 Expert 2GB
You're going to have to rejoin it to your table. Try something like:

Expand|Select|Wrap|Line Numbers
  1.  
  2. select * from Auction_1
  3. where bid_amount = (SELECT MAX(Bid_Amount) FROM Auction_1)
  4.  
  5.  
This will get all records with the highest amount. Just in case there are "ties" :)

Happy Coding!!!

~~ CK
Mar 22 '10 #2
omar999
120 100+
this worked a treat !

your a life saver - thank you : )
Mar 22 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: skidvd | last post by:
Hello: I have just recently converted to using the InnoDB table type so that I can enforce FOREIGN key constraints. I have been using MyISAM tables (accessed via JDBC) successfully for some...
11
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
38
by: Lasse Vågsæther Karlsen | last post by:
After working through a fair number of the challenges at www.mathschallenge.net, I noticed that some long-running functions can be helped *a lot* by caching their function results and retrieving...
10
by: Antanas | last post by:
The problem is that when AddID is used multiple times in the same select statement, it returns the same value in all places. How could I force function AddID to increment OBJECTID sequence? Here...
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
4
by: Jason Kumpf | last post by:
OK I've been staring at this code all day and still with everything I have tried I cannot figure out two problems I am having. Once is why the space limit for the directory I create in the code...
48
by: Jimmy | last post by:
thanks to everyone that helped, unfortunately the code samples people gave me don't work. here is what i have so far: <% Dim oConn, oRS, randNum Randomize() randNum = (CInt(1000 * Rnd) + 1) *...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
5
by: Matthew Wells | last post by:
I have a listbox set to simple multi select. For this example, users only select one item at a time. I have command buttons on the form for First, Previous, Next, Last, New (record). The form...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.