I need to write a query of the scenario but I am lost writing it.
Assume there are two tables Items and Bids. The items are being selected via some sort of filter
SELECT i.* FROM Items i WHERE i.Id = 2
Now there is a Bids table having "ItemId" column to link Items to Bids. Now I want all items' data with HighestBid, LowestBid and TotalBids and I am trying this but it's not working.
SELECT i.*, hal.*
FROM Items i, (SELECT MAX(b.OfferAmount), MIN(b.OfferAmount), COUNT(b.*) FROM Bids b WHERE b.ItemId = i.Id) As hal
WHERE i.Id = 2
Is there something wrong with this?