mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
This commit is contained in:
parent
478cabee22
commit
a4a56a9b6c
41
tests/queries/0_stateless/03041_select_with_query_result.sql
Normal file
41
tests/queries/0_stateless/03041_select_with_query_result.sql
Normal file
@ -0,0 +1,41 @@
|
||||
-- https://github.com/ClickHouse/ClickHouse/issues/44153
|
||||
DROP TABLE IF EXISTS parent;
|
||||
DROP TABLE IF EXISTS join_table_1;
|
||||
DROP TABLE IF EXISTS join_table_2;
|
||||
|
||||
CREATE TABLE parent(
|
||||
a_id Int64,
|
||||
b_id Int64,
|
||||
c_id Int64,
|
||||
created_at Int64
|
||||
)
|
||||
ENGINE=MergeTree()
|
||||
ORDER BY (a_id, b_id, c_id, created_at);
|
||||
|
||||
CREATE TABLE join_table_1(
|
||||
a_id Int64,
|
||||
b_id Int64
|
||||
)
|
||||
ENGINE=MergeTree()
|
||||
ORDER BY (a_id, b_id);
|
||||
|
||||
CREATE TABLE join_table_2(
|
||||
c_id Int64,
|
||||
created_at Int64
|
||||
)
|
||||
ENGINE=MergeTree()
|
||||
ORDER BY (c_id, created_at);
|
||||
|
||||
WITH with_table as (
|
||||
SELECT p.a_id, p.b_id, p.c_id FROM parent p
|
||||
LEFT JOIN join_table_1 jt1 ON jt1.a_id = p.a_id AND jt1.b_id = p.b_id
|
||||
LEFT JOIN join_table_2 jt2 ON jt2.c_id = p.c_id
|
||||
WHERE
|
||||
p.a_id = 0 AND (jt2.c_id = 0 OR p.created_at = 0)
|
||||
)
|
||||
SELECT p.a_id, p.b_id, COUNT(*) as f_count FROM with_table
|
||||
GROUP BY p.a_id, p.b_id;
|
||||
|
||||
DROP TABLE IF EXISTS parent;
|
||||
DROP TABLE IF EXISTS join_table_1;
|
||||
DROP TABLE IF EXISTS join_table_2;
|
Loading…
Reference in New Issue
Block a user