ClickHouse/tests/queries/0_stateless/02006_test_positional_arguments.reference
2021-10-20 07:52:39 +00:00

154 lines
2.7 KiB
Plaintext

-- { echo }
select x3, x2, x1 from test order by 1;
1 100 100
10 1 10
100 10 1
select x3, x2, x1 from test order by x3;
1 100 100
10 1 10
100 10 1
select x3, x2, x1 from test order by 1 desc;
100 10 1
10 1 10
1 100 100
select x3, x2, x1 from test order by x3 desc;
100 10 1
10 1 10
1 100 100
insert into test values (1, 10, 200), (10, 1, 200), (100, 100, 1);
select x3, x2 from test group by x3, x2;
200 1
10 1
200 10
1 100
100 10
select x3, x2 from test group by 1, 2;
200 1
10 1
200 10
1 100
100 10
select x1, x2, x3 from test order by x3 limit 1 by x3;
100 100 1
10 1 10
1 10 100
1 10 200
select x1, x2, x3 from test order by 3 limit 1 by 3;
100 100 1
10 1 10
1 10 100
1 10 200
select x1, x2, x3 from test order by x3 limit 1 by x1;
100 100 1
10 1 10
1 10 100
select x1, x2, x3 from test order by 3 limit 1 by 1;
100 100 1
10 1 10
1 10 100
select x3, x2, x1 from test order by x3 + x3;
1 100 100
1 100 100
10 1 10
100 10 1
200 10 1
200 1 10
select x3, x2, x1 from test order by 1 + 1;
1 100 100
1 100 100
10 1 10
100 10 1
200 10 1
200 1 10
select x3, x2, x1 from test order by (x3 + x3) * x1;
1 100 100
100 10 1
10 1 10
1 100 100
200 10 1
200 1 10
select x3, x2, x1 from test order by (1 + 1) * 3;
1 100 100
100 10 1
10 1 10
1 100 100
200 10 1
200 1 10
select x2, x1 from test group by x2 + x1; -- { serverError 215 }
select x2, x1 from test group by 1 + 2; -- { serverError 215 }
select x3, x2, x1 from test order by 1;
1 100 100
1 100 100
10 1 10
100 10 1
200 10 1
200 1 10
select x3 + 1, x2, x1 from test order by 1;
2 100 100
2 100 100
11 1 10
101 10 1
201 10 1
201 1 10
select x3, x3 - x2, x2, x1 from test order by 2;
1 -99 100 100
1 -99 100 100
10 9 1 10
100 90 10 1
200 190 10 1
200 199 1 10
select x3, if(0, x3, plus(x1, x2)), x1 + x2 from test order by 2;
200 11 11
200 11 11
100 11 11
10 11 11
1 200 200
1 200 200
select max(x1), x2 from test group by 2 order by 1, 2;
1 10
10 1
100 100
select max(x1), x2 from test group by 1, 2; -- { serverError 43 }
select x1 + x2, x3 from test group by x1 + x2, x3;
11 100
200 1
11 200
11 10
select x3, x2, x1 from test order by x3 * 2, x2, x1; -- check x3 * 2 does not become x3 * x2
1 100 100
1 100 100
10 1 10
100 10 1
200 1 10
200 10 1
select x3, x2, x1 from test order by 1 + 1, 2, 1;
1 100 100
1 100 100
10 1 10
100 10 1
200 1 10
200 10 1
explain syntax select x1, x3 from test group by 1 + 2, 1, 2;
SELECT
x1,
x3
FROM test
GROUP BY
x1 + x3,
x1,
x3
explain syntax select x1 + x3, x3 from test group by 1, 2;
SELECT
x1 + x3,
x3
FROM test
GROUP BY
x1 + x3,
x3
create table test2(x1 Int, x2 Int, x3 Int) engine=Memory;
insert into test2 values (1, 10, 100), (10, 1, 10), (100, 100, 1);
select x1, x1 * 2, max(x2), max(x3) from test2 group by 2, 1, x1 order by 1, 2, 4 desc, 3 asc;
1 2 10 100
10 20 1 10
100 200 100 1