对于数值型数组,返回相邻两个元素的差(从后者中减去前者)构成的数组。
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] |
+----------------------------------------+