Skip to content
Advertisement

SQL max product price [closed]

I have a table of products and each record has the price it was sold at, which can vary

Product          Price
a                2
a                3
a                4
a                1
b                10
b                15
b                20

I want a query which will give be the max price at which product a was sold and max price at which product b was sold and nothing more

I have thousands of products so case will not help

Advertisement

Answer

Use MAX and Group By

SELECT Product, MAX(Price)
FROM YourTable
GROUP BY Product

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement