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 |
firejackmusic
Starting Member
15 Posts |
Posted - 2009-07-10 : 02:49:42
|
I was given a query while back for proxy, I have slightly altered it I have 3 columnsminprice max price start priceI have two tables - products and bidhistory - if there is a bidhistory I want to show the bid in 3 stages1. Get the the startprice bid if no one as bid2. get the bidhistory highest bid but not the high proxy bid by one user3. get the bidhistory lowest bid if another user has bid higher , hope this makes sense, bit like that well know on line auction company ....;pI'm trying to avoid ifs and would like to build it into the query rather than the codeSELECT Price.MINPrice, Price.MAXPrice, MainProducts.startPriceFROM products AS MainProducts INNER JOIN (SELECT products.idproduct, MIN(COALESCE (bidhistory.bidAmount, products.Price)) AS MINPrice, MAX(COALESCE (bidhistory.bidAmount, products.Price)) AS MAXPrice FROM products LEFT OUTER JOIN bidhistory ON products.idproduct = bidhistory.idProduct GROUP BY products.idproduct) AS Price ON Price.idproduct = MainProducts.idproduct |
|
firejackmusic
Starting Member
15 Posts |
Posted - 2009-07-16 : 04:20:14
|
Anyone got any idea how to build this? |
|
|
|
|
|