Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9269

Re: Calculated column based on two values in single column in SAP HANA

$
0
0

Hi Gayathri,

 

the easiest way to implement this in SQL would be with the LAG() window function, no need for temp tables & self joins.

Window Functions - SAP HANA SQL and System Views Reference - SAP Library

 

It could be something like:

SELECT DATE, TIME, MEASURE, (MEASURE - LAG(MEASURE, 1) OVER (ORDER BY DATE, TIME)) AS MEASURE_DIF FROM TABLE;

Use coalesce over the calculated column if you'd like the null value to be 0.

 

And as mentioned, you can encapsulate this SQL code in a SQLScript calculation view.

 

Best,

Henrique.


Viewing all articles
Browse latest Browse all 9269

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>