Skip to content

function group_concat ([order by ... desc...]), 'order by' and 'desc' do not work as same as mysql #820

@irene-coming

Description

@irene-coming
  • dble version:
    5.6.29-dble-9.9.9.9-08136d5-20181106070356

  • preconditions :
    no

  • configs:
    schema.xml

<table name="aly_test" dataNode="dn1,dn2,dn3,dn4" rule="hash-four" />
  • steps:
    step1. execute sqls with both dble and mysql:
CREATE TABLE `aly_test` (
  `id` int(11) DEFAULT NULL,
  `name` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
insert into aly_test values(1,'a'),(null,'b'),(2,null),(1,'d'),(null,'c'),(3,'a'),(null,'b'),(null,'c'),(null,'b');

step2.execute sql with mysql

mysql> select *, group_concat(name order by name) from aly_test group by id;
+------+------+----------------------------------+
| id   | name | group_concat(name order by name) |
+------+------+----------------------------------+
| NULL | b    | b,b,b,c,c                        |
|    1 | a    | a,d                              |
|    2 | NULL | NULL                             |
|    3 | a    | a                                |
+------+------+----------------------------------+
4 rows in set (0.00 sec)

mysql> select *, group_concat(distinct name order by name desc separator ':') from aly_test group by id;
+------+------+--------------------------------------------------------------+
| id   | name | group_concat(distinct name order by name desc separator ':') |
+------+------+--------------------------------------------------------------+
| NULL | b    | c:b                                                          |
|    1 | a    | d:a                                                          |
|    2 | NULL | NULL                                                         |
|    3 | a    | a                                                            |
+------+------+--------------------------------------------------------------+
4 rows in set (0.01 sec)

step3. execute same sql as step2 with dble:

mysql> select *, group_concat(name order by name) from aly_test group by id;
+------+------+---------------------------------------------------------+
| id   | name | GROUP_CONCAT(aly_test.name ORDER BY name SEPARATOR ',') |
+------+------+---------------------------------------------------------+
| NULL | b    | b,c,b,c,b                                               |
|    1 | a    | a,d                                                     |
|    2 | NULL | NULL                                                    |
|    3 | a    | a                                                       |
+------+------+---------------------------------------------------------+
4 rows in set (0.01 sec)
mysql> select *, group_concat(distinct name order by name desc separator ':') from aly_test group by id;
+------+------+-----------------------------------------------------------------------+
| id   | name | GROUP_CONCAT(DISTINCT aly_test.name ORDER BY name DESC SEPARATOR ':') |
+------+------+-----------------------------------------------------------------------+
| NULL | b    | b:c                                                                   |
|    1 | a    | a:d                                                                   |
|    2 | NULL | NULL                                                                  |
|    3 | a    | a                                                                     |
+------+------+-----------------------------------------------------------------------+
4 rows in set (0.01 sec)
  • expect result:
    1. step3 get same result as step2
  • real result:
    1.
  • supplements:
    1.autotest already append at version:674072355e4d2a503d15ce3234884f71ab0ad03a aggregate.sql, if issue fix, need update std_result

/label ~BUG

Metadata

Metadata

Assignees

Labels

Aggregate functionresolveproblem has been fixed by developerverifiedissue's resolve was verified by tester

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions