Quantcast
Channel: SCN: Message List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 8968

Re: Multidimensional arrays in SQLScript

$
0
0

Yes I think it is possible since you have fixed set of columns (some hints below on possible logic)

 

First you have to select the last row which you can do easily by just doing max(row_no) . If you don't have row_no in your input then you can generate row_num column additionally in SQL Script

 

Then you use CASE STATEMENT to find the index of column which has max value. If you have fixed no, of columns in input table then you can write something like

 

CASE

        WHEN A >= B AND A >= C THEN 1

        WHEN B >= A AND B >= C THEN 2

        WHEN C >= A AND C >= B THEN 3

        END  AS max_colid

 

It is easier to get the rowid with min value by just doing ORDER BY on last column and selecting top row.

 

Then you need to write 1 more SELECT statement with CASE

 

 

 

select CASE WHEN :max_colid = 1 THEN A

  WHEN :max_colid = 2 THEN B

  WHEN :max_colid = 3 THEN C

  END AS INTERSECT_VAL

from table where row_num = :min_rowid;

 

I am avoiding providing complete script logic so that you have satisfaction of solving on your own.


Viewing all articles
Browse latest Browse all 8968

Trending Articles



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