Successful implementation of Cumulative Sum in SAP HANA

A cumulative sum is a sequence of partial sums of a given sequence. For example, the cumulative sums of the sequence {a,b,c,...}, are aa+ba+b+c, …. Cumulative sums.
Cumulative Sum:Cumulative sums, or running totals, are used to display the total sum of data as it grows with time (or any other series or progression). This lets you view the total contribution so far of a given measure against time.
If you’re a frequent user of the SUM function, you may occasionally want to take the cumulative SUM of a value across a table. For example, if you have a table that outlines product sales by month for an entire year, you may want to insert a cumulative SUM column that shows year-to-date sales at the end of each month.
This can be easily accomplished using relative and absolute cell references combined with the SUM function. Let’s take a look at how it works.
Following are the steps to implement Cumulative Sum in SAP HANA
Step 1: Create a table and Insert the data into the table.
Created “CUMMULATIVE_SUM” table using SQL Console.

Insert the data into “CUMMULATIVE_SUM” table


Step 2 : Create Script based calculation view with the name “CLV_CUMMULATIVE_SUM_SCRIPT_BASED”

Click on Finish button

/********* Begin Procedure Script ************/  /********* Begin Procedure Script ************/
BEGIN 
  var_out =SELECT ID,NAME,MARKS,SUM(MARKS) OVER (ORDER BY ID) AS
CUMMULATIVE_SUM FROM “KRISHNA_REDDY”.”CUMMULATIVE_SUM” ORDER BY ID;
END
/********* End Procedure Script ************/
Save and Validate the view then
Save and Activate the View
Step 3: Check the output
click on Data preview button to see the output



Comments


  1. Thank you for giving this best information. It’s a very nice topic
    SAP HANA Remote Online Access

    ReplyDelete

Post a Comment

Popular posts from this blog

How To Implement Smart Data Access in SAP HANA

How To Implement SQL Analytic Privilege in SAP HANA