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

Re: how to find a maximum of set of records in HANA?

$
0
0

One possible way that I think of is using Window operator.

Here is a quick solution you can try. Not sure if the performance is acceptable on large dataset though.

In this example ID is the record id assumed to be in a sequence.

 

  select id, value,

  greatest(

  COALESCE (lead(value) over ( order by id), value),

  COALESCE (lead(value,2) over ( order by id), value),

  COALESCE (lead(value,3) over ( order by id), value),

  COALESCE (lead(value,4) over ( order by id), value),

  COALESCE (lead(value,5) over ( order by id), value)

 

 

  ) as rollinggreatest

from <table>;


Viewing all articles
Browse latest Browse all 8451

Trending Articles



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