2020-01-28 19:39:52 +00:00
|
|
|
DROP TABLE IF EXISTS test.basic_00040;
|
2018-08-07 17:08:51 +00:00
|
|
|
|
2020-01-28 19:39:52 +00:00
|
|
|
CREATE MATERIALIZED VIEW test.basic_00040
|
2018-08-07 17:08:51 +00:00
|
|
|
ENGINE = AggregatingMergeTree(StartDate, (CounterID, StartDate), 8192)
|
|
|
|
POPULATE AS
|
|
|
|
SELECT
|
|
|
|
CounterID,
|
|
|
|
StartDate,
|
|
|
|
sumState(Sign) AS Visits,
|
|
|
|
uniqState(UserID) AS Users
|
|
|
|
FROM test.visits
|
|
|
|
GROUP BY CounterID, StartDate;
|
|
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
StartDate,
|
|
|
|
sumMerge(Visits) AS Visits,
|
|
|
|
uniqMerge(Users) AS Users
|
2020-01-28 19:39:52 +00:00
|
|
|
FROM test.basic_00040
|
2018-08-07 17:08:51 +00:00
|
|
|
GROUP BY StartDate
|
|
|
|
ORDER BY StartDate;
|
|
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
StartDate,
|
|
|
|
sumMerge(Visits) AS Visits,
|
|
|
|
uniqMerge(Users) AS Users
|
2020-01-28 19:39:52 +00:00
|
|
|
FROM test.basic_00040
|
2018-12-29 22:11:00 +00:00
|
|
|
WHERE CounterID = 942285
|
2018-08-07 17:08:51 +00:00
|
|
|
GROUP BY StartDate
|
|
|
|
ORDER BY StartDate;
|
|
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
StartDate,
|
|
|
|
sum(Sign) AS Visits,
|
|
|
|
uniq(UserID) AS Users
|
|
|
|
FROM test.visits
|
2018-12-29 22:11:00 +00:00
|
|
|
WHERE CounterID = 942285
|
2018-08-07 17:08:51 +00:00
|
|
|
GROUP BY StartDate
|
|
|
|
ORDER BY StartDate;
|
|
|
|
|
|
|
|
|
2020-01-28 19:39:52 +00:00
|
|
|
DROP TABLE test.basic_00040;
|