ClickHouse/tests/queries/0_stateless/00938_test_retention_function.sql
Ivan 97f2a2213e
Move all folders inside /dbms one level up (#9974)
* Move some code outside dbms/src folder
* Fix paths
2020-04-02 02:51:21 +03:00

15 lines
918 B
SQL

DROP TABLE IF EXISTS retention_test;
CREATE TABLE retention_test(date Date, uid Int32)ENGINE = Memory;
INSERT INTO retention_test SELECT '2018-08-06', number FROM numbers(8);
INSERT INTO retention_test SELECT '2018-08-07', number FROM numbers(6);
INSERT INTO retention_test SELECT '2018-08-08', number FROM numbers(7);
SELECT uid, retention(date = '2018-08-06', date = '2018-08-07') AS r FROM retention_test WHERE date IN ('2018-08-06', '2018-08-07') GROUP BY uid ORDER BY uid LIMIT 5;
SELECT '----------';
SELECT uid, retention(1, date = '2018-08-06', date = '2018-08-07') AS r FROM retention_test WHERE date IN ('2018-08-06', '2018-08-07') GROUP BY uid ORDER BY uid LIMIT 5;
SELECT '----------';
SELECT uid, retention(uid % 2 = 0, date = '2018-08-06', date = '2018-08-07') AS r FROM retention_test WHERE date IN ('2018-08-06', '2018-08-07') GROUP BY uid ORDER BY uid LIMIT 5;
DROP TABLE IF EXISTS retention_test;