HANA OPEN SQL

HANA OPEN SQL_第1张图片


HANA OPEN SQL_第2张图片


HANA OPEN SQL_第3张图片


HANA OPEN SQL_第4张图片


HANA OPEN SQL_第5张图片


HANA OPEN SQL_第6张图片


HANA OPEN SQL_第7张图片


HANA OPEN SQL_第8张图片


HANA OPEN SQL_第9张图片


HANA OPEN SQL_第10张图片


HANA OPEN SQL_第11张图片


HANA OPEN SQL_第12张图片
HANA OPEN SQL_第13张图片


5、字符串操作

*字符串直接拼接

select  mblnr,

mjahr,

zeile,

concat( bwart,lgort ) as desc  "只能2个字符串拼接

from mseg

into table @data(gt_data01) "放到WHERE后面

      up to 10 rows.

*带空格拼接

select mblnr,

mjahr,

zeile,

concat_with_space( bwart,lgort,3 ) as desc  "用3个空格拼接

from mseg

into table @data(gt_data02)    "放到最后面

      up to 10 rows.

*计算字符串长度

select mblnr,

mjahr,

zeile,

charg,

length( charg ) as desc

from mseg

into table @data(gt_data05)    "放到最后面

      up to 10 rows.

*字符串替换

select mblnr,

mjahr,

zeile,

matnr,

replace( matnr,'1','X' ) as desc  "用X替换M

from mseg

into table @data(gt_data07)

      up to 10 rows.

*从左边开始,以指定字符串填充到指定长度

select mblnr,

mjahr,

zeile,

lgort,

lpad( lgort,10,'X' ) as desc  "从左边开始,用X填充,拼接上LGORT的总长度为10

from mseg

into table @data(gt_data08)

      up to 10 rows.

*从左边开始去掉指定的字符串

*中间的不会去掉

*可以用来去前导0

select mblnr,

mjahr,

zeile,

matnr,

ltrim( matnr,'0' ) as desc  "从左边开始,去掉前面的M

from mseg

into table @data(gt_data09)

      up to 10 rows.

*查找字符串第一次出现所在的位置

select mblnr,

mjahr,

zeile,

lgort,

instr( lgort,'1' ) as desc  "字符串3对应MATNR的第一次出现的位置,从左边开始

from mseg

into table @data(gt_data10)

      up to 10 rows.

*多个字符串拼接

select mblnr,

mjahr,

zeile,

matnr,

bwart,

lgort,

( matnr && bwart && lgort ) as desc  "多个字符串拼接

from mseg

into table @data(gt_data11)

      up to 10 rows.

你可能感兴趣的:(HANA OPEN SQL)