array_difference
功能
对于数值型数组,返回相邻两个元素的差(从后者中减去前者)构成的数组。
语法
output array_difference(input)
参数说明
- input:数值型数组。
返回值说明
类型为 ARRAY (与输入 input
保持一致),内容为将输入 input
中相邻两元素的差,长度与 input
保持一致。
示例
示例一:
mysql> SELECT array_difference([342, 32423, 213, 23432]);
+-----------------------------------------+
| array_difference([342,32423,213,23432]) |
+-----------------------------------------+
| [0,32081,-32210,23219] |
+-----------------------------------------+
示例二:
mysql> SELECT array_difference([342, 32423, 213, null, 23432]);
+----------------------------------------------+
| array_difference([342,32423,213,NULL,23432]) |
+----------------------------------------------+
| [0,32081,-32210,null,null] |
+----------------------------------------------+
示例三:
mysql> SELECT array_difference([1.2, 2.3, 3.2, 4324242.55]);
+--------------------------------------------+
| array_difference([1.2,2.3,3.2,4324242.55]) |
+--------------------------------------------+
| [0,1.1,0.9,4324239.35] |
+--------------------------------------------+
示例四:
mysql> SELECT array_difference([false, true, false]);
+----------------------------------------+
| array_difference([FALSE, TRUE, FALSE]) |
+----------------------------------------+
| [0,1,-1] |
+----------------------------------------+