FLOOR()
函数说明
FLOOR()函数返回不大于某个数字的相应数位的数。
函数语法
1. > FLOOR(number, decimals)
2. > FLOOR(number)
参数释义
| 参数 | 说明 |
|---|---|
| number | 必要参数,任何当前支持的数值数据 |
| decimals | 可选参数,代表小数点后的位数。默认值为0,代表四舍五入为整数,当为负数时四舍五入到小数点前的数位。 |
示例
1. > drop table if exists t1;
2. > create table t1(a int ,b float);
3. > insert into t1 values(1,0.5);
4. > insert into t1 values(2,0.499);
5. > insert into t1 values(3,0.501);
6. > insert into t1 values(4,20.5);
7. > insert into t1 values(5,20.499);
8. > insert into t1 values(6,13.500);
9. > insert into t1 values(7,-0.500);
10. > insert into t1 values(8,-0.499);
11. > insert into t1 values(9,-0.501);
12. > insert into t1 values(10,-20.499);
13. > insert into t1 values(11,-20.500);
14. > insert into t1 values(12,-13.500);
15. > select a,floor(b) from t1;
16. +------+----------+
17. | a | floor(b) |
18. +------+----------+
19. | 1 | 0.0000 |
20. | 2 | 0.0000 |
21. | 3 | 0.0000 |
22. | 4 | 20.0000 |
23. | 5 | 20.0000 |
24. | 6 | 13.0000 |
25. | 7 | -1.0000 |
26. | 8 | -1.0000 |
27. | 9 | -1.0000 |
28. | 10 | -21.0000 |
29. | 11 | -21.0000 |
30. | 12 | -14.0000 |
31. +------+----------+
32. > select sum(floor(b)) from t1;
33. +---------------+
34. | sum(floor(b)) |
35. +---------------+
36. | -6.0000 |
37. +---------------+
38. > select a,sum(floor(b)) from t1 group by a order by a;
39. +------+---------------+
40. | a | sum(floor(b)) |
41. +------+---------------+
42. | 1 | 0.0000 |
43. | 2 | 0.0000 |
44. | 3 | 0.0000 |
45. | 4 | 20.0000 |
46. | 5 | 20.0000 |
47. | 6 | 13.0000 |
48. | 7 | -1.0000 |
49. | 8 | -1.0000 |
50. | 9 | -1.0000 |
51. | 10 | -21.0000 |
52. | 11 | -21.0000 |
53. | 12 | -14.0000 |
54. +------+---------------+
限制
MatrixOne目前只支持在查询表的时候使用函数,不支持单独使用函数。
