how to group by and count using MySQL

后端 未结 4 1185
死守一世寂寞
死守一世寂寞 2021-01-29 01:51

I have data which looks like this:

ID  post_author post_title  guid
3309    21  Should somebody not yet on SQL 2008 wait for SQL 2008 R2, since it\'s near release?  h         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-29 02:13

    Write a SQL FUNCTION - call it for instance, guid_extract(guid), which extracts the pertinent info, then you can add it to a column in your select::

    SELECT stuff, otherstuff, guid_extract(guid) as site
      ...
      GROUP BY site;
    

提交回复
热议问题