I am trying to work out the min
and max
price on a table of items:
item [itemcode] [itemname] [iteminfo] [price]
I want to get not only the min and max price but also what the item is: so query result needs to be cheapest item, itemname item info, then want to change the syntax for the max version of it. Most expensive item, itemname and iteminfo etc select min(price) from item
This works fine. Returns the min same with max. But, when I try to get item information, it returns all rows of the table not just the single row where its cheapest or most expensive. For example:
select min(price) as lowest, itemcode, itemname, iteminfo
from item
group by itemname
I'm not sure, what I'm doing wrong? Can anyone help me?
If you need to display the row with a mininum price for a particular itemname kindly use the below