Find sum based on another column and use aggregate function in SQL

Viewed 26

I am working on SQL and I want to achieve this output in SQL using HIVE, here is the problem statement

I have columns Item, Cost and price. The output I am expecting to have a following columns

  1. 25% cost- Which is the 25% value of cost.
  2. total_price- Its a sum of price values based on Item.
  3. cumulative_price-Based on item it's a sum of cumulative price.
  4. I want to flag those records which has cumulative_price>25%cost value

Item: Cost: 25%Cost: price :total_price: cumulative_price: flag

0 Answers
Related