Company: Phone pe ML engineer_19april
Difficulty: medium
Problem Description You are managing a database of products across various categories. Your task is to identify the most expensive product(s) within each category. Write a SQL query to retrieve the name, cost, and category of the products that have the maximum cost in their respective categories. If multiple products in the same category share the same maximum cost, include all of them in the result. Schema Table: products Field Type Description product_id Integer The unique ID of the product. product_name String The name of the product. cost Integer The price of the product (in USD). category String The category to which the product belongs. Required Output The result should contain the following columns in the specified order and with the exact headers provided: Field Type Description product_name String The name of the product. product_cost Integer The maximum cost found in that category. product_category String The category name. Constraints or Notes Ordering: Sort the final output