Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROLLUP with HAVING - incorrect results #3756

Closed
reflection opened this issue Dec 5, 2018 · 1 comment
Closed

ROLLUP with HAVING - incorrect results #3756

reflection opened this issue Dec 5, 2018 · 1 comment

Comments

@reflection
Copy link
Contributor

# ClickHouse
CREATE TABLE test (
  a Nullable(String),
  b Nullable(String)
) ENGINE = Memory;

INSERT INTO test VALUES (NULL, NULL);
INSERT INTO test VALUES ('a', NULL);
INSERT INTO test VALUES ('a', 'b');

SELECT a, b, count(*) FROM test GROUP BY a, b WITH ROLLUP HAVING a IS NOT NULL and b IS NOT NULL;
┌─a────┬─b────┬─count()─┐
│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │       1 │
│ a    │ ᴺᵁᴸᴸ │       1 │
│ a    │ b    │       1 │
└──────┴──────┴─────────┘
┌─a────┬─b────┬─count()─┐
│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │       1 │
│ a    │ ᴺᵁᴸᴸ │       2 │
└──────┴──────┴─────────┘
┌─a────┬─b────┬─count()─┐
│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │       3 │
└──────┴──────┴─────────┘

6 rows in set. Elapsed: 0.010 sec.

SELECT a, b, count(*) FROM test GROUP BY a, b WITH ROLLUP HAVING a IS NOT NULL;
┌─a────┬─b────┬─count()─┐
│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │       1 │
│ a    │ ᴺᵁᴸᴸ │       1 │
│ a    │ b    │       1 │
└──────┴──────┴─────────┘
┌─a────┬─b────┬─count()─┐
│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │       1 │
│ a    │ ᴺᵁᴸᴸ │       2 │
└──────┴──────┴─────────┘
┌─a────┬─b────┬─count()─┐
│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │       3 │
└──────┴──────┴─────────┘

6 rows in set. Elapsed: 0.008 sec


# Postgresql
CREATE TABLE test (
  a TEXT,
  b TEXT
);

INSERT INTO test VALUES (NULL, NULL);
INSERT INTO test VALUES ('a', NULL);
INSERT INTO test VALUES ('a', 'b');

SELECT a, b, count(*) FROM test GROUP BY ROLLUP(a, b) HAVING a IS NOT NULL and b IS NOT NULL;
 a | b | count
---+---+-------
 a | b |     1
(1 row)

SELECT a, b, count(*) FROM test GROUP BY ROLLUP(a, b) HAVING a IS NOT NULL;
 a | b | count
---+---+-------
 a | b |     1
 a |   |     1
 a |   |     2
(3 rows)
@blinkov blinkov added the issue label Dec 6, 2018
@reflection
Copy link
Contributor Author

Hi, any update on this issue as it's been over a week? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants