[thelist] Quick SQL Help Please

Rob Smith rob.smith at THERMON.com
Thu Oct 28 10:52:24 CDT 2004


>SELECT MAX(t.Bid) AS LatestBid, t.ID, t.By FROM `TBayBid` t
>GROUP BY t.ID ORDER BY t.ID

And actually you need to GROUP BY t.ID, t.By. If you use a Max() something,
you need to group by all the unmaxed stuff.

I lieu of that: the results were:

 52		1		Jane
 3		2		Jane
 6		3		Jane

I ended up doing a three part process:

>SELECT MAX(t.Bid) AS LatestBid, t.ID FROM `TBayBid` t
>GROUP BY t.ID ORDER BY t.ID

 52		1
 3		2
 6		3

On that recordset, I grabbed the Name per row, then the actual item name per
the ID field. I wouldn't have given up so easily if I was working for eBay
as this solution is highly inefficient. This was for about 20 items in a
fundraiser for United Way. 

We raised over $250 with this little system I built :-)

Rob


More information about the thelist mailing list