x
create table Item
(
Itemid int primary key ,
ItemName varchar(100),
CalorificValue int,
price int
)
Task: what item has the highest price followed by the highest calorific value?
My query solution:
Select Itemname
from Item
where price = (Select max(price) from Item)
and CalorificValue = (Select max(CalorificValue) from Item)
But I’m not getting the answer. Can anyone solve this issue?
Advertisement
Answer
Try the following with limit
select
TOP 1 ItemName
from yourTable
order by
price desc,
CalorificValue desc