Displaying other field while using MAX in a query

  • Thread starter Thread starter VJ
  • Start date Start date
V

VJ

Hi,

I have a sample DB with ItemID, Description and Selling
Price. I need to perform a query that will return the MAX
SellingPrice in the DB and also the corresponding ItemID
and Description.

Could someone tell me how to do it?

Thanx a lot
VJ
 
If you want just one row with the top selling price, try
something along the lines of
SELECT TOP 1 ItemId, Description, SellingPrice
FROM YourTable
ORDER BY SellingPrice DESC

If you want all rows with the top selling price, try
SELECT ItemId, Description, SellingPrice
FROM YourTable
WHERE SellingPrice IN (SELECT Max(SellingPrice) FROM YourTable)

Hope This Helps
Gerald Stanley MCSD
 
Back
Top