Given a table like this:
id     number     anotherNumber
1      1          10
2      1          20
3      2          20
4      2          10
5      3          10
If I run the query:
Select *, GROUP_CONCAT(number)
FROM docs
GROUP BY number
I will get:
id  number  anotherNumber   GROUP_CONCAT(number)
1   1       10              1,1
3   2       20              2,2
5   3       10              3
However I want to get:
id  number  anotherNumber   GROUP_CONCAT(number)
1   1       20              1,1
3   2       20              2,2
5   3       10              3
Basically I want the numbers in the anotherNumber column to be sorted in DSEC order - it should always be the highest one.
I know you can put an ORDER BYin the GROUP_CONCAT but this will only affect the concatenated values, not the "merged ones". So is there a simple way?
 
     
    