mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
81 lines
1.5 KiB
Plaintext
81 lines
1.5 KiB
Plaintext
-- { echo }
|
|
set enable_positional_arguments = 1;
|
|
drop table if exists test;
|
|
create table test (col1 Int32, col2 Int32, col3 Int32) engine = Memory();
|
|
insert into test select number, number, 1 from numbers(2);
|
|
insert into test select number, number, 2 from numbers(2);
|
|
insert into test select number, number, 3 from numbers(2);
|
|
insert into test select number, number, 4 from numbers(2);
|
|
insert into test select number, number, 2 from numbers(2);
|
|
select * from test where col1 = 1 order by 1;
|
|
1 1 1
|
|
1 1 2
|
|
1 1 2
|
|
1 1 3
|
|
1 1 4
|
|
select * from test where col2 = 1 order by 3;
|
|
1 1 1
|
|
1 1 2
|
|
1 1 2
|
|
1 1 3
|
|
1 1 4
|
|
insert into test select number, number+1, 1 from numbers(2);
|
|
insert into test select number, number+1, 2 from numbers(2);
|
|
insert into test select number, number+1, 3 from numbers(2);
|
|
insert into test select number, number+1, 4 from numbers(2);
|
|
insert into test select number, number+1, 2 from numbers(2);
|
|
select * from test order by col3 limit 1 by col3;
|
|
0 0 1
|
|
0 1 2
|
|
0 0 3
|
|
0 1 4
|
|
select * from test order by 3 limit 1 by 3;
|
|
0 0 1
|
|
0 0 2
|
|
0 1 3
|
|
0 0 4
|
|
select col1, col2 from test group by col1, col2 order by col1, col2;
|
|
0 0
|
|
0 1
|
|
1 1
|
|
1 2
|
|
select col1, col2 from test group by 1, 2 order by 1, 2;
|
|
0 0
|
|
0 1
|
|
1 1
|
|
1 2
|
|
select col2, col3 from test group by col3, col2 order by col3, col2;
|
|
0 1
|
|
1 1
|
|
2 1
|
|
0 2
|
|
1 2
|
|
2 2
|
|
0 3
|
|
1 3
|
|
2 3
|
|
0 4
|
|
1 4
|
|
2 4
|
|
select col2, col3 from test group by 3, 2 order by 3, 2;
|
|
0 1
|
|
1 1
|
|
2 1
|
|
0 2
|
|
1 2
|
|
2 2
|
|
0 3
|
|
1 3
|
|
2 3
|
|
0 4
|
|
1 4
|
|
2 4
|
|
select col2 from test group by 2 order by 2;
|
|
0
|
|
1
|
|
2
|
|
select col2 + 100 from test group by 2 order by col2;
|
|
100
|
|
101
|
|
102
|