write query to find out next highest cost by category

write query to find out next highest cost by category

Input:











Expected Output:











Solve:

SELECT  productName, cost,LEAD(cost, 1) OVER (PARTITION BY category ORDER BY cost asc) AS Lead_amount,categoryFROM cost_table ;


Comments