Home > Blockchain >  I need to obtain the product name which unit price is higher
I need to obtain the product name which unit price is higher

Time:12-10

CREATE TABLE Products (
Product Name varchar(30),
Unit Price int
)

INSERT INTO Products VALUES
('soap', 40),
('brushteeth', 30)

CodePudding user response:

Try this:

SELECT ProductName FROM Products
WHERE UnitPrice = (SELECT max(UnitPrice) FROM Products)

CodePudding user response:

SELECT ProductName
FROM Products
WHERE UnitPrice = (
                       SELECT MAX(UnitPrice)
                       FROM Products
                  )

This should work. However, I'm pretty sure there is a more optimized way to do that.

  • Related