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.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Query for a proxy bid

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 columns

minprice max price start price

I have two tables - products and bidhistory - if there is a bidhistory I want to show the bid in 3 stages

1. Get the the startprice bid if no one as bid

2. get the bidhistory highest bid but not the high proxy bid by one user

3. get the bidhistory lowest bid if another user has bid higher , hope this makes sense, bit like that well know on line auction company ....;p

I'm trying to avoid ifs and would like to build it into the query rather than the code


SELECT Price.MINPrice, Price.MAXPrice, MainProducts.startPrice
FROM 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?
Go to Top of Page
   

- Advertisement -