Highest Priced Product per Category

Company: Phone pe ML engineer_19april

Difficulty: medium

Problem Statement

Highest Priced Product per Category An online store keeps its catalogue in the table products . Every product belongs to exactly one category. Write an SQL query that returns the name, cost and category of every product whose cost is the maximum cost within its own category . If several products of the same category share that maximum cost, return all of them. Table: products Column Data Type Description product_id INTEGER Unique id of the product product_name TEXT Name of the product (two products may have the same name) cost INTEGER Price of the product in US dollars, for example 80 means 80 USD category TEXT Category the product belongs to Expected Output Return the following columns, in this order: Column Description product_name Name of the product product_cost Cost of the product, which is the maximum cost in its category product_category Category of the product Rules A product is returned when no product of the same category costs more. Products of other categories do not matter