Nikita Mikhaylov 2024-04-10 17:07:42 +02:00
parent 4fdef93d6b
commit 597d174234
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,2 @@
5
6

View File

@ -0,0 +1,30 @@
-- https://github.com/ClickHouse/ClickHouse/issues/54954
DROP TABLE IF EXISTS loans;
CREATE TABLE loans (loan_number int, security_id text) ENGINE=Memory;
SET allow_experimental_analyzer=1;
INSERT INTO loans VALUES (1, 'AAA');
INSERT INTO loans VALUES (1, 'AAA');
INSERT INTO loans VALUES (1, 'AAA');
INSERT INTO loans VALUES (1, 'AAA');
INSERT INTO loans VALUES (1, 'AAA');
INSERT INTO loans VALUES (1, 'BBB');
INSERT INTO loans VALUES (1, 'BBB');
INSERT INTO loans VALUES (1, 'BBB');
INSERT INTO loans VALUES (1, 'BBB');
INSERT INTO loans VALUES (1, 'BBB');
INSERT INTO loans VALUES (1, 'BBB');
with block_0 as (
select * from loans
),
block_1 as (
select sum(loan_number) as loan_number from block_0 group by security_id
)
select loan_number from block_1 where loan_number > 3 settings prefer_column_name_to_alias = 1;
DROP TABLE IF EXISTS loans;