Using COUNT in GROUP_CONCAT

前端 未结 5 1019
陌清茗
陌清茗 2021-02-19 12:04

This is my table:

  id  | fk_company
-------------------
  1   |     2    
  2   |     2    
  3   |     2    
  4   |     4    
  5   |     4    
  6   |     11          


        
5条回答
  •  情书的邮戳
    2021-02-19 12:40

    SELECT A,  
    GROUP_CONCAT(B SEPARATOR '/') AS 'Category',  
    GROUP_CONCAT(C SEPARATOR '/') AS 'ALIAS_NAME',COUNT('ALIAS_NAME') AS 'Count'  
    FROM carnews  
    ...  
    ...
    GROUP BY 1
    ORDER BY 4 DESC  
    

    This works well in my case.

提交回复
热议问题