cambyzju opened a new issue, #15142:
URL: https://github.com/apache/doris/issues/15142

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Version
   
   latest
   
   ### What's Wrong?
   
   `> select id,sum(v1) v,sum(v2) v2 from test_d group by id having (v2>1);`
   `ERROR 1105 (HY000): errCode = 2, detailMessage = HAVING clause not produced 
by aggregation output (missing from GROUP BY clause?): (`v2` > 1)`
   
   
   ### What You Expected?
   
   fix
   
   ### How to Reproduce?
   
   1. create table 
   ```
   CREATE TABLE `test_d` (
     `id` int(11) NULL,
     `v1` bigint(20) NULL,
     `v2` bigint(20) NULL
   ) ENGINE=OLAP
   DUPLICATE KEY(`id`)
   COMMENT 'OLAP'
   DISTRIBUTED BY HASH(`id`) BUCKETS 1
   PROPERTIES (
   "replication_allocation" = "tag.location.default: 1",
   "in_memory" = "false",
   "storage_format" = "V2",
   "disable_auto_compaction" = "false"
   );
   ```
   
   2. insert data
   `insert into test_d values(1,1,1),(2,2,2),(2,3,3);`
   
   3. wrong sql:
   ```
   > select id,sum(v1) v,sum(v2) v2 from test_d group by id having (v2>4);
   ERROR 1105 (HY000): errCode = 2, detailMessage = HAVING clause not produced 
by aggregation output (missing from GROUP BY clause?): (`v2` > 4)
   ```
   
   4. correct sql:
   ```
   > select id,sum(v1) v,sum(v2) v2 from test_d group by id having (v2>4 AND 
v>0);
   +------+------+------+
   | id   | v    | v2   |
   +------+------+------+
   |    2 |    5 |    5 |
   +------+------+------+
   ```
   
   ### Anything Else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to