mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 02:41:59 +00:00
26 lines
448 B
MySQL
26 lines
448 B
MySQL
|
DROP TABLE IF EXISTS table1;
|
||
|
|
||
|
create table table1 (
|
||
|
col1 Int32,
|
||
|
col2 Int32
|
||
|
)
|
||
|
ENGINE = MergeTree
|
||
|
partition by tuple()
|
||
|
order by col1;
|
||
|
|
||
|
INSERT INTO table1 VALUES (1, 2), (1, 4);
|
||
|
|
||
|
with NULL as pid
|
||
|
select a.col1, sum(a.col2) as summ
|
||
|
from table1 a
|
||
|
prewhere (pid is null or a.col2 = pid)
|
||
|
group by a.col1;
|
||
|
|
||
|
with 123 as pid
|
||
|
select a.col1, sum(a.col2) as summ
|
||
|
from table1 a
|
||
|
prewhere (pid is null or a.col2 = pid)
|
||
|
group by a.col1;
|
||
|
|
||
|
DROP TABLE table1;
|