Poor HAVING, nobody likes him 🙂
SELECT
ProductID, BaseSupplierID,
MIN(CASE WHEN SupplierID <> BaseSupplierID THEN Price END) AS LowestPrice,
MIN(CASE WHEN SupplierID = BaseSupplierID THEN Price END) AS BaseSupplierPrice
FROM dbo.test1
GROUP BY
ProductID, BaseSupplierID
HAVING
MIN(CASE WHEN SupplierID <> BaseSupplierID THEN Price END) <
MIN(CASE WHEN SupplierID = BaseSupplierID THEN Price END)
SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.