prajwalbandak commented on issue #28070:
URL: 
https://github.com/apache/shardingsphere/issues/28070#issuecomment-1696055097

   Hey @54uso ,In your second query, you're trying to filter the groups using 
the condition HAVING cnt < 30000. However, this condition is not applied 
correctly. The HAVING clause filters the results of the GROUP BY operation, and 
it works on the result of the aggregate functions (like COUNT, MAX, etc.) 
applied to the groups.
   Can you try this code:
    `ResultSet resultSet1 = 
dataSource.getConnection().createStatement().executeQuery(
       "SELECT trade_status, count(1) as cnt, max(id) as mid " +
       "FROM loan_order_info " +
       "WHERE trade_status > 0 AND id > 0 " +
       "GROUP BY trade_status " +
       "HAVING cnt < 30000"
   );
   
   while (resultSet1.next()) {
       System.out.printf("resultSet1 group by having: %d %d\n", 
resultSet1.getInt("trade_status"), resultSet1.getInt("cnt"));
   }
   ` 
   let me know if this works or not. 
   Thanks.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to