首页 > 数据库技术 > 详细

SAPHANA学习(14):SQL Function(N)

时间:2020-10-28 19:58:05      阅读:36      评论:0      收藏:0      [点我收藏+]

/*

100.NCHAR

NCHAR(<number>)

将数字转换为Union编码字符

*/

SELECT NCHAR(65) FROM DUMMY;

/*

101.NEWUID

在SAP HANA数据库创建唯一标识符

*/

SELECT NEWUID() FROM DUMMY;

/*

102.

NORMALIZE( <character_value_expression> [ , <normalized_format> ] )

<character_value_expression>:VARCHAR,NVARCHAR

<normalized_format> ::= NFC | NFD | NFKC | NFKD

*/

--不存在
--SELECT NORMALIZE(‘?‘) FROM DUMMY;

/*

103.NTH_VALUE

Aggregate function:

NTH_VALUE( <expression>, <position> <order_by_clause> )

Window function:

NTH_VALUE( <expression>, <position> <order_by_clause> ) <window_specification>

<order_by_clause> ::= ORDER BY <order_by_expression> [, <order_by_expression> [,...] ]

 <order_by_expression> ::=

  <column_name> [ <collate_clause> ] [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ]

  | <column_position> [ <collate_clause> ] [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ]

 <collate_clause> ::= COLLATE <collation_name>

 

NTILE( <number_of_buckets> ) <window_specification>

*/

--返回根据COL2排序后,COL1的第二个值
SELECT NTH_VALUE(COL1,2 ORDER BY COL2) FROM TEST_DECIMAL;

SELECT "CLASS","VAL","OFFSET",
       NTILE(3) OVER (PARTITION BY "CLASS" ORDER BY "VAL") AS "NTILE", 
       FIRST_VALUE("VAL") OVER (PARTITION BY "CLASS" ORDER BY "VAL") AS "FIRST", 
       LAST_VALUE("VAL") OVER (PARTITION BY "CLASS" ORDER BY "VAL") AS "LAST", 
       NTH_VALUE("VAL",4) OVER (PARTITION BY "CLASS" ORDER BY "VAL") AS "NTH"
  FROM TEST_RANK;

/*

104.NULLIF

NULLIF(<expression1>, <expression2>)

比较<exp1>,<exp2>是否相等,相等返回null;

如果不相等,返回<exp1>;

*/

SELECT NULLIF(diff, same) FROM DUMMY;

/*

105.NUMTOHEX

NUMTOHEX(<integer> [, <integer>])

返回hex类型数据

*/

--不存在
--SELECT NUMTOHEX(-1) FROM DUMMY;
--SELECT NUMTOHEX(1323) FROM DUMMY;

 

SAPHANA学习(14):SQL Function(N)

原文:https://www.cnblogs.com/tangToms/p/13892811.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!