/ 详情

使用HAVING字句,直接查询失败

Backlog
Opened this issue  
2020-12-15 11:22

1、依赖的版本

org.apache.shardingsphere
sharding-jdbc-spring-boot-starter
4.1.1

2、使用Hikari作为连接池
3、逻辑SQL:

2020-12-15 11:04:21.486 INFO  [tp-nio-5000-exec-8] - ShardingSphere-SQL                                           : Logic SQL: SELECT
        user_id  FROM report_disease
        WHERE disease_code= 3
         
            AND user_id IN
             (  
                ?
             , 
                ?
             ) 
         
         
            AND start_time LIKE CONCAT(?,'%')
         
        GROUP BY user_id HAVING COUNT(*) > 0

4、真是的SQL

2020-12-15 11:04:21.486 INFO  [tp-nio-5000-exec-8] - ShardingSphere-SQL                                           : Actual SQL: ds0 ::: SELECT
        user_id  FROM report_disease_202011
        WHERE disease_code= 3
         
            AND user_id IN
             (  
                ?
             , 
                ?
             ) 
         
         
            AND start_time LIKE CONCAT(?,'%')
         
        GROUP BY user_id ORDER BY user_id ASC  HAVING COUNT(*) > 0 ::: [515ac560b49946459cdf7e67d1468d5f, 9b42bc14701c40e68cad9f08333402d9, 2019-02-13 16:45:29]

5、运行的结果
查询直接报错,sharding-jdbc添加了ORDER BY user_id ASC,在使用HAVING COUNT() > 0导致失败了
6、期望结果,不自动添加ORDER BY user_id ASC
SELECT
user_id FROM report_disease
WHERE disease_code= 3
GROUP BY user_id HAVING COUNT(
) > 0

Comments (0)

城堡 created任务
展开全部操作日志

Sign in to comment

状态
Assignees
Milestones
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
Branches
Planed to start   -   Planed to end
-
Top level
Priority
参与者(1)