标签:art values order view www money material agg string
create table agg_source( id UInt8, name String, city String, money UInt32 ) engine=MergeTree() partition by city order by id;
insert into agg_source values (1, ‘aa‘, ‘SD‘, 200), (2, ‘bb‘, ‘SD‘, 200), (3, ‘cc‘, ‘SH‘, 200), (4, ‘dd‘, ‘BJ‘, 200), (5, ‘ee‘, ‘SZ‘, 200), (6, ‘ff‘, ‘BJ‘, 100), (7, ‘gg‘, ‘HZ‘, 100), (8, ‘ww‘, ‘WH‘, 100)
create materialized view agg_view engine = AggregatingMergeTree() partition by city order by city populate as select city, uniqState(name) name, sumState(money) money from agg_source group by city;
select city, uniqMerge(name), sumMerge(money) from agg_view group by city;
转自 https://www.cnblogs.com/crazy-rabbit/p/14708579.html#_labelTop
标签:art values order view www money material agg string
原文地址:https://www.cnblogs.com/abc608088/p/14852283.html