2018-08-24 16:35:00 +00:00
|
|
|
CREATE DATABASE IF NOT EXISTS test;
|
|
|
|
DROP TABLE IF EXISTS test.decimal;
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS test.decimal
|
|
|
|
(
|
|
|
|
d1 DECIMAL(9, 8),
|
|
|
|
d2 DECIMAL(18, 8),
|
|
|
|
d3 DECIMAL(38, 8)
|
|
|
|
)
|
|
|
|
ENGINE = MergeTree
|
|
|
|
PARTITION BY toInt32(d1)
|
|
|
|
ORDER BY (d2, d3);
|
|
|
|
|
2018-08-27 16:16:16 +00:00
|
|
|
INSERT INTO test.decimal (d1, d2, d3) VALUES (4.2, 4.2, 4.2);
|
|
|
|
|
2018-09-05 13:28:51 +00:00
|
|
|
SELECT count() FROM test.decimal WHERE d1 = toDecimal32('4.2', 8);
|
|
|
|
SELECT count() FROM test.decimal WHERE d1 != toDecimal32('4.2', 8);
|
|
|
|
SELECT count() FROM test.decimal WHERE d1 < toDecimal32('4.2', 8);
|
|
|
|
SELECT count() FROM test.decimal WHERE d1 > toDecimal32('4.2', 8);
|
|
|
|
SELECT count() FROM test.decimal WHERE d1 <= toDecimal32('4.2', 8);
|
|
|
|
SELECT count() FROM test.decimal WHERE d1 >= toDecimal32('4.2', 8);
|
2018-08-27 16:16:16 +00:00
|
|
|
|
2018-08-24 16:35:00 +00:00
|
|
|
INSERT INTO test.decimal (d1, d2, d3)
|
|
|
|
SELECT toDecimal32(number % 10, 8), toDecimal64(number, 8), toDecimal128(number, 8) FROM system.numbers LIMIT 50;
|
|
|
|
|
|
|
|
SELECT count() FROM test.decimal WHERE d1 = 1;
|
2018-08-27 16:16:16 +00:00
|
|
|
SELECT * FROM test.decimal WHERE d1 > 5 AND d2 < 30 ORDER BY d2 DESC;
|
|
|
|
SELECT * FROM test.decimal WHERE d1 IN(1, 3) ORDER BY d2;
|
2018-08-24 16:35:00 +00:00
|
|
|
|
|
|
|
DROP TABLE test.decimal;
|