给数据库的字段取别名的时候能够直接食用’AS’关键字来命名。
1 | select count(title) AS title_count from x |
给字段当中的值,也就是内容取别名来代替的时候,使用’case when then end’来命名1
select case when title='a' then BF4 when title='b' then BF3 else BFHL end as title from x
关于group by的使用,最好与聚合函数count,sum等一起使用,这样能进行更好的分类处理,按照group中比较多的列来进行计算。具体的实现方式下次在看。1
select title from x group by title