FLOOR()
Description
The FLOOR() function returns the largest round number that is less than or equal to the number.
Syntax
1. > FLOOR(number, decimals)
2. > FLOOR(number)
Arguments
| Arguments | Description |
|---|---|
| number | Required. Any numeric data type supported now. |
| decimals | Optional. An integer that represents the number of decimal places. By default it is zero, which means to round to an integer. decimals may also be negative. |
Examples
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. +------+---------------+
Constraints
Currently, MatrixOne doesn’t support select function() without from tables.
