SAP HANA:多列的最小值

时间:2016-05-15 14:44:36

标签: sql sap hana

我在SAP HANA索引服务器中有一些列:

  if (handle instanceof net.Socket) {
    message.type = 'net.Socket';
  } else if (handle instanceof net.Server) {
    message.type = 'net.Server';
  } else if (handle instanceof process.binding('tcp_wrap').TCP ||
             handle instanceof process.binding('pipe_wrap').Pipe) {
    message.type = 'net.Native';
  } else if (handle instanceof dgram.Socket) {
    message.type = 'dgram.Socket';
  } else if (handle instanceof process.binding('udp_wrap').UDP) {
    message.type = 'dgram.Native';
  } else {
    throw new TypeError("This handle type can't be sent");
  }

如何获得每行的minium值?

预期结果:

ID | COL_1 | COL_2 | COL_3
---+-------+-------+------
 1 |     5 |     3 |    2
 2 |     7 |     9 |    8
 3 |     5 |     4 |    6

到目前为止,我试过

ID | MIN   
---+-------
 1 |     2 
 2 |     7 
 3 |     4 

但是SELECT ID, min(COL_1, COL_2, COL_3) FROM ... 似乎一次只支持两个col。

1 个答案:

答案 0 :(得分:5)

假设没有值为NULL,请使用LEAST()

select least(col_1, col_2, col3_3)
from . . .