Skip to content
Advertisement

mysql – GROUP_CONCAT rows into a string

I have a following result set:

I need to have the following output

Here’s as far as I could get:

How can I distinguish rows based on ai_result column and put them separately. Something like GROUP_CONCAT(hash) AS matched, GROUP_CONCAT(hash) AS non_matched?

Advertisement

Answer

Try using conditional aggregation:

enter image description here

Demo

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement