GROUP_CONCAT can't order by

ThunderBirdsX3

I can't make GROUP_CONCAT make ORDER BY.

SELECT GROUP_CONCAT(`cdlAmountA`+`cdlAmountB`+`cdlAmountC` SEPARATOR "|")
     FROM `creditlogs`
     WHERE `cdlDate` = "2016-04-07"
          AND compID = "AIR"
     ORDER BY `creditID`

This is out put.

96276.9|7960.2|0|0

But it's not right, The right answer is.

0|96276.9|7960.2|0

How can i make it right. And this is database.

creditID | cdlAmountA | cdlAmountB | cdlAmountC
-----------------------------------------------
1        | 0          | 0          | 0
2        | 34948.7    | 61328.2    | 0
3        | 4510.2     | 3450       | 0  
4        | 0          | 0          | 0
Giorgos Betsos

The ORDER BY clause has to be used inside GROUP_CONCAT function like this:

SELECT GROUP_CONCAT(`cdlAmountA`+`cdlAmountB`+`cdlAmountC` 
                    ORDER BY `creditID` SEPARATOR "|" )
FROM `creditlogs`
WHERE `cdlDate` = "2016-04-07" AND compID = "AIR"

Demo here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

GROUP_CONCAT can't order by

From Dev

Can't get my head around GROUP_CONCAT

From Dev

Alphabetically order in group_concat

From Dev

BigQuery GROUP_CONCAT and ORDER BY

From Dev

MySQL - GROUP_CONCAT returns duplicate data, can't use DISTINCT

From Dev

MySQL - GROUP_CONCAT returns duplicate data, can't use DISTINCT

From Dev

mysql multiple group_concat order preservation

From Dev

Trouble with joining and the order of GROUP_CONCAT data

From Dev

MySQL ORDER BY field created by GROUP_CONCAT()

From Dev

group_concat doesn't work with count

From Dev

MYSQL - GROUP_CONCAT AND FIND_IN_SET are mixing values/order?

From Dev

MySql select order by rand not working with GROUP_CONCAT

From Dev

Issue with GROUP_CONCAT AND ORDER BY FIELD in MySQL query

From Dev

PHP group_concat inserting seperator or order by results in no data

From Dev

How can I combine GROUP_CONCAT and LEFT JOIN?

From Dev

Can we make a DISTINCT of a group_concat(distinct somefield)?

From Dev

How can I use GROUP_CONCAT in Rails?

From Dev

How can I use group_concat on an entire subquery?

From Dev

Can't order in query

From Dev

Mysql Group_concat where in again group concat how can i manage

From Dev

MySQL's Group_Concat function miss the nulls. How can group the rows including NULLs.

From Dev

mysql query, how can i get top 5 downloads with GROUP_CONCAT

From Dev

Using GROUP_CONCAT creatively to avoid a query...can groups of records be retrieved?

From Dev

Group_concat of orders_ qty can not give result in laravel & mysql

From Dev

mysql query, how can i get top 5 downloads with GROUP_CONCAT

From Dev

ORDER BY: Can't merge two column conditions `order` and id DESC

From Dev

Can't make Spring aspect lowest order

From Dev

Why can't styles be removed in forward order?

From Dev

MySQL: can't order one side of a union

Related Related

  1. 1

    GROUP_CONCAT can't order by

  2. 2

    Can't get my head around GROUP_CONCAT

  3. 3

    Alphabetically order in group_concat

  4. 4

    BigQuery GROUP_CONCAT and ORDER BY

  5. 5

    MySQL - GROUP_CONCAT returns duplicate data, can't use DISTINCT

  6. 6

    MySQL - GROUP_CONCAT returns duplicate data, can't use DISTINCT

  7. 7

    mysql multiple group_concat order preservation

  8. 8

    Trouble with joining and the order of GROUP_CONCAT data

  9. 9

    MySQL ORDER BY field created by GROUP_CONCAT()

  10. 10

    group_concat doesn't work with count

  11. 11

    MYSQL - GROUP_CONCAT AND FIND_IN_SET are mixing values/order?

  12. 12

    MySql select order by rand not working with GROUP_CONCAT

  13. 13

    Issue with GROUP_CONCAT AND ORDER BY FIELD in MySQL query

  14. 14

    PHP group_concat inserting seperator or order by results in no data

  15. 15

    How can I combine GROUP_CONCAT and LEFT JOIN?

  16. 16

    Can we make a DISTINCT of a group_concat(distinct somefield)?

  17. 17

    How can I use GROUP_CONCAT in Rails?

  18. 18

    How can I use group_concat on an entire subquery?

  19. 19

    Can't order in query

  20. 20

    Mysql Group_concat where in again group concat how can i manage

  21. 21

    MySQL's Group_Concat function miss the nulls. How can group the rows including NULLs.

  22. 22

    mysql query, how can i get top 5 downloads with GROUP_CONCAT

  23. 23

    Using GROUP_CONCAT creatively to avoid a query...can groups of records be retrieved?

  24. 24

    Group_concat of orders_ qty can not give result in laravel & mysql

  25. 25

    mysql query, how can i get top 5 downloads with GROUP_CONCAT

  26. 26

    ORDER BY: Can't merge two column conditions `order` and id DESC

  27. 27

    Can't make Spring aspect lowest order

  28. 28

    Why can't styles be removed in forward order?

  29. 29

    MySQL: can't order one side of a union

HotTag

Archive