mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
137 lines
3.7 KiB
Plaintext
137 lines
3.7 KiB
Plaintext
-- { echo }
|
|
select 1 intersect select 1;
|
|
1
|
|
select 2 intersect select 1;
|
|
select 1 except select 1;
|
|
select 2 except select 1;
|
|
2
|
|
select number from numbers(20) intersect select number from numbers(5, 5);
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
select number from numbers(10) except select number from numbers(5);
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
select number, number+10 from numbers(12) except select number+5, number+15 from numbers(10);
|
|
0 10
|
|
1 11
|
|
2 12
|
|
3 13
|
|
4 14
|
|
select 1 except select 2 intersect select 1;
|
|
1
|
|
select 1 except select 2 intersect select 2;
|
|
1
|
|
select 1 intersect select 1 except select 2;
|
|
1
|
|
select 1 intersect select 1 except select 1;
|
|
select 1 intersect select 1 except select 2 intersect select 1 except select 3 intersect select 1;
|
|
1
|
|
select 1 intersect select 1 except select 2 intersect select 1 except select 3 intersect select 2;
|
|
1
|
|
select 1 intersect select 1 except select 2 intersect select 1 except select 3 intersect select 2 except select 1;
|
|
select number from numbers(10) except select 5;
|
|
0
|
|
1
|
|
2
|
|
3
|
|
4
|
|
6
|
|
7
|
|
8
|
|
9
|
|
select number from numbers(100) intersect select number from numbers(20, 60) except select number from numbers(30, 20) except select number from numbers(60, 20);
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
|
28
|
|
29
|
|
50
|
|
51
|
|
52
|
|
53
|
|
54
|
|
55
|
|
56
|
|
57
|
|
58
|
|
59
|
|
select * from (select 1 intersect select 1);
|
|
1
|
|
with (select number from numbers(10) intersect select 5) as a select a * 10;
|
|
50
|
|
with (select 5 except select 1) as a select a except select 5;
|
|
with (select number from numbers(10) intersect select 5) as a select a intersect select 1;
|
|
with (select number from numbers(10) intersect select 5) as a select a except select 1;
|
|
5
|
|
select count() from (select number from numbers(10) except select 5);
|
|
9
|
|
select count() from (select number from numbers(1000000) intersect select number from numbers(200000, 600000));
|
|
600000
|
|
select count() from (select number from numbers(100) intersect select number from numbers(20, 60) except select number from numbers(30, 20) except select number from numbers(60, 20));
|
|
20
|
|
select count() from (select number from numbers(100) intersect select number from numbers(20, 60) except select number from numbers(30, 20) except select number from numbers(60, 20) union all select number from numbers(100, 10));
|
|
30
|
|
select count() from (select number from numbers(1000000) intersect select number from numbers(200000, 600000) except select number from numbers(300000, 200000) except select number from numbers(600000, 200000));
|
|
200000
|
|
select count() from (select 1 intersect select 1) limit 100;
|
|
1
|
|
select count() from (select 1 except select 2) limit 100;
|
|
1
|
|
with (select count() from (select 1 union distinct select 2 except select 1)) as max
|
|
select count() from (select 1 union all select max) limit 100;
|
|
2
|
|
select 1 union all select 1 intersect select 1;
|
|
1
|
|
1
|
|
select 1 union all select 1 intersect select 2;
|
|
1
|
|
select * from (select 1 union all select 2 union all select 3 union all select 4 except select 3 union all select 5) order by 1;
|
|
1
|
|
2
|
|
4
|
|
5
|
|
select * from (select 1 union all select 2 union all select 3 union all select 4 intersect select 3 union all select 5) order by 1;
|
|
1
|
|
2
|
|
3
|
|
5
|
|
select * from (select 1 union all select 2 union all select 3 union all select 4 intersect select 3 union all select 5 except select 1) order by 1;
|
|
2
|
|
3
|
|
5
|
|
select 1 intersect (select 1 except select 2);
|
|
1
|
|
select 1 union all select 2 except (select 2 except select 1 union all select 1) except select 4;
|
|
select 1 intersect select count() from (select 1 except select 2 intersect select 2 union all select 1);
|
|
explain syntax select 1 intersect select 1;
|
|
SELECT 1
|
|
INTERSECT
|
|
SELECT 1
|
|
explain syntax select 1 except select 1;
|
|
SELECT 1
|
|
EXCEPT
|
|
SELECT 1
|
|
explain syntax select 1 union all select 2 except (select 2 except select 1 union all select 1) except select 4;
|
|
SELECT 1
|
|
UNION ALL
|
|
SELECT 2
|
|
EXCEPT
|
|
SELECT 2
|
|
EXCEPT
|
|
SELECT 1
|
|
UNION ALL
|
|
SELECT 1
|
|
EXCEPT
|
|
SELECT 4
|