dble icon indicating copy to clipboard operation
dble copied to clipboard

The results of executing sql contained ”group by columnName=“ is not consistent with MYSQL

Open jndxcaiwei opened this issue 2 years ago • 0 comments

  • dble version:
    3.21.10.0

  • configs:

sharding.xml

<shardingTable name="Employee" shardingNode="dn3,dn4" function="func_hashString" shardingColumn="deptname"/>

<function name="func_hashString" class="StringHash">
      <property name="partitionCount">2</property>
      <property name="partitionLength">1</property>
      <property name="hashSlice">0:2</property>
  </function>
  • steps:
    step1. create table:
   CREATE TABLE `Employee` (
  `name` varchar(250) NOT NULL,
  `empid` int(11) NOT NULL,
  `deptname` varchar(250) NOT NULL,
  `level` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

step2. prepare data:

insert into Employee values('Harry',3415,'Finance','P7'),('Sally',2242,'Sales','P7'),('George',3401,'Finance','P8'),('Harriet',2202,'Sales','P8'),('Mary',1257,'Human Resources','P7'),('LiLi',9527,'Human Resources','P9'),('Tom',7012,'Market','P9'),('Tony',3052,'Market','P10'),('Jessi',7948,'Finance','P8');

step3. execute SQL:

select deptname,count(*) from Employee group by deptname='Human Resources';
  • MYSQL result:
+-----------------+----------+
| deptname        | count(*) |
+-----------------+----------+
| Finance         |        7 |
| Human Resources |        2 |
+-----------------+----------+
  • dble result:
+-----------------+----------+
| deptname        | count(*) |
+-----------------+----------+
| Sales           |        7 |
| Human Resources |        2 |
+-----------------+----------+

jndxcaiwei avatar Mar 10 '22 08:03 jndxcaiwei