Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
esambath
Yak Posting Veteran
89 Posts |
Posted - 2008-07-30 : 12:23:51
|
| Hi Friendsi need result for maximum amount of offer bidding amount.For ExampleTbl_Bids========id ,vehicleID, offer, eAccountID1 23 1500 12 44 2000 53 23 2200 74 23 2800 9Tbl_eAccount============eAccountId, FirstName, LastName, Email1 Smith Jop smith@yahoo.com5 Johncy Jack Jack@redif.com7 Diana Sam sam@yahoo.com 9 Jecy Jacoff Jacoff@yahoo.comTbl_Vehicle===========VehicleID, v_ModelID, TitleHolder, TypeAuction, Expiration23 Yamaha LA single 30/7/2008 22:00:0044 Ducati LXAA njk 31/7/2008 22:00:00Expected outputWho is bid maximum amount for vehicle 23 is : FirstName, Email, Maximum amount of offer, VehicleID, ExpirationJecy , Jacoff@yahoo.com , 2800 , 23 , 30/7/2008 22:00:00 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-30 : 13:23:06
|
| [code]SELECT a.FirstName,a.Email,b.offer as [Maximum amount of offer],v.VehicleID,v.ExpirationFROM Tbl_Vehicle vINNER JOIN Tbl_Bids bON b.vehicleID=v.VehicleIDINNER JOIN (SELECT vehicleID,MAX(offer) AS MaxBid FROM Tbl_Bids GROUP BY vehicleID) mxbdON mxbd.vehicleID=b.vehicleIDAND mxbd.MaxBid=b.offerINNER JOIN Tbl_eAccount aON a.eAccountId=b.eAccountIdWHERE v.VehicleID=23[/code] |
 |
|
|
|
|
|
|
|