I have a query like SELECT CONCAT(manufacturer, ':', COUNT(*)) AS count FROM cars GROUP BY manufacturer
which returns something like:
+---------+
| count |
+---------+
| ford:10 |
| fiat:5 |
| kia:2 |
+---------+
Now I want to GROUP_CONCAT those rows into 1 row like:
+------------------------+
| result |
+------------------------+
| ford:10, fiat:5, kia:2 |
+------------------------+
But there's already a GROUP BY, so GROUP_CONCAT doesn't work. How can I achieve this with MySQL?
select Group_Concat(count SEPERATOR ',') from
(SELECT CONCAT(manufacturer, ':', COUNT(*)) AS count
FROM cars GROUP BY manufacturer) AS A
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.